#K70712. Maximum Product of Two Elements

    ID: 33370 Type: Default 1000ms 256MiB

Maximum Product of Two Elements

Maximum Product of Two Elements

You are given an array of n positive integers. Your task is to select two distinct elements a and b from the array and compute the value of \((a-1) \times (b-1)\).

More formally, if the array is given by \(A = [a_1, a_2, \dots, a_n]\), you need to find two different indices \(i\) and \(j\) (\(i \neq j\)) such that the product \((a_i - 1) \times (a_j - 1)\) is maximized.

Note: The numbers in the array are guaranteed to be positive.

inputFormat

The input consists of two lines:

  1. The first line contains an integer \(n\) indicating the number of elements in the array.
  2. The second line contains \(n\) space-separated positive integers.

outputFormat

Output a single integer, which is the maximum product \((a-1) \times (b-1)\) for any two distinct elements in the array.

## sample
4
1 5 4 5
16