#C927. Maximum Product of Two Elements

    ID: 53344 Type: Default 1000ms 256MiB

Maximum Product of Two Elements

Maximum Product of Two Elements

Given an array of integers, your task is to compute the maximum product of any two distinct elements in the array.

The product can be derived either from the two largest numbers in the array or from the product of the two smallest numbers (which may be negative and yield a positive product). Formally, if the array is \(a_1, a_2, \dots, a_n\), you need to find

[ \max{a_i \times a_j \mid 1 \leq i < j \leq n} ]

It is guaranteed that the array contains at least two elements.

inputFormat

The input is given via standard input. The first line contains an integer n (\(2 \le n \le 10^5\)), which represents the number of elements in the array. The second line contains n space-separated integers, each representing an element of the array. Each integer value lies in the range \([-10^4, 10^4]\).

outputFormat

Print a single integer: the maximum product of any two distinct elements in the array.

## sample
5
1 4 3 -6 -7
42

</p>