#C8617. Maximum Product of Two Distinct Elements
Maximum Product of Two Distinct Elements
Maximum Product of Two Distinct Elements
You are given an array of n integers. The task is to find the maximum product obtainable by multiplying any two distinct elements from the array.
Mathematically, if the array is \(a_1, a_2, \dots, a_n\), you need to compute:
\( \max_{1 \le i < j \le n} (a_i \times a_j) \)
It is guaranteed that n \ge 2
.
inputFormat
The input is given via stdin with the following format:
- The first line contains a single integer
n
, the number of elements. - The second line contains
n
space-separated integers representing the elements of the array.
outputFormat
Output a single integer representing the maximum product of any two distinct elements in the array. The result should be printed to stdout.
## sample4
1 2 3 4
12
</p>