#K70712. Maximum Product of Two Elements
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:
- The first line contains an integer \(n\) indicating the number of elements in the array.
- 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.
## sample4
1 5 4 5
16