#C1906. Maximum Pair Product

    ID: 45163 Type: Default 1000ms 256MiB

Maximum Pair Product

Maximum Pair Product

You are given an array of n integers which may include positive numbers, negative numbers, and zero. Your task is to find the maximum product obtainable from any two distinct elements in the array.

The problem can be formulated as follows:

Given an array \(A = [a_1, a_2, \ldots, a_n]\), find \[ \max\{a_i \times a_j : 1 \le i

where (\text{max1}) and (\text{max2}) are the two largest numbers in the array, and (\text{min1}) and (\text{min2}) are the two smallest numbers in the array (which may be negative).

inputFormat

The input is given via standard input (stdin) in the following format:

n
a1 a2 ... an

Here, the first line contains a single integer n which is the number of elements in the array, and the second line contains n integers separated by spaces.

outputFormat

Output a single integer to standard output (stdout), which is the maximum product of any two distinct elements in the given array.

## sample
5
1 10 3 -2 5
50