276. Largest Product of Two
Print the largest product obtainable from two values at different positions.
The trap is negatives. Two large negatives multiply to a large POSITIVE, so the answer is not always the two largest values.
-10 -9 1 2 -> 90 (from -10 x -9, not 1 x 2)
After sorting there are exactly two candidates: the product of the two largest, and the product of the two smallest. The answer is whichever is bigger.
Constraints - `2 ≤ n ≤ 200000` - `-1000000000 ≤ a[i] ≤ 1000000000`
Input
The first line contains an integer n.
The second line contains n integers.
Output
Print one integer, the largest product of two values at different positions.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.