#C8179. Maximum Product of Two Elements
Maximum Product of Two Elements
Maximum Product of Two Elements
You are given a sequence of n integers. Your task is to determine the largest product that can be obtained by multiplying any two distinct elements from the array.
The answer is the maximum between the product of the two largest numbers and the product of the two smallest numbers (which can be large if both are negative). Formally, if the sorted array is \(a_1 \le a_2 \le \cdots \le a_n\), then the answer is:
\(\max(a_1 \times a_2,\, a_{n-1} \times a_n)\)
Input is provided via standard input and output should be printed to standard output.
inputFormat
The first line contains a single integer n (\(n \ge 2\)), the number of elements in the array. The second line contains n space-separated integers which represent the array.
outputFormat
Output a single integer — the maximum product of any two distinct elements.
## sample5
1 10 2 6 5
60
</p>