Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/minmax-35-eng-katta-kopaytma

Largest product of two numbers

Medium 1000 ms 128 MB 51%
Share

A positive integer $N$ and $N$ integers are given. Find the largest value of the product of two elements at different positions $A_{i} * A_{j}$ ($i \ne j$).

Choosing the largest product of two elements

Input

The first line contains a positive integer $N$. The next line contains $N$ integers $A_{i}$.

Output

One integer.

Note

$2 \le N \le 10^{5}$
$-10^{9} \le A_{i} \le 10^{9}$

Examples

Input #1
5
-8 3 -6 5 2
Output #1
48
Input #2
2
-4 7
Output #2
-28

Sign in to submit a solution

Signing up is free and takes a minute.