#K72222. Maximum Product of Two Integers

    ID: 33706 Type: Default 1000ms 256MiB

Maximum Product of Two Integers

Maximum Product of Two Integers

Given an integer n and a list of n integers, your task is to determine the maximum product of any two distinct integers in the list.

Let the list be sorted as \(a_1 \le a_2 \le \ldots \le a_n\). The maximum product will be the maximum of the product of the two smallest numbers and the product of the two largest numbers:

\[ \text{result} = \max(a_1 \times a_2,\; a_{n-1} \times a_n)\]

Please note: The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The first line contains an integer n representing the number of integers in the list. The second line contains n space-separated integers.

For example:

4
1 2 3 4

outputFormat

Output a single integer which is the maximum product of any two integers from the list.

For example, for the above input the output should be:

12
## sample
4
1 2 3 4
12

</p>