#K54082. Maximum Product Pair
Maximum Product Pair
Maximum Product Pair
Given an array of integers, your task is to compute the maximum product of any two distinct numbers in the array. Note that the maximum product can come either from the product of the two largest numbers or from the product of the two smallest (possibly negative) numbers.
In mathematical form, if the sorted array is \(a_1, a_2, \dots, a_n\), then the answer is given by:
[ \max(a_1 \times a_2,; a_{n-1} \times a_n) ]
It is guaranteed that the array has at least two elements.
inputFormat
The input is given via standard input. The first line contains an integer (n) ((n \ge 2)) representing the number of elements in the array. The second line contains (n) space-separated integers.
outputFormat
Output the maximum product of any two integers from the array to standard output.## sample
4
1 2 3 4
12
</p>