MinMax
You are given N integer a1, ..., aN. Among those N numbers you have to find the four numbers (A, B, C, D) for which it is true that:
- A * B is maximal for all A = ai and B = aj, where i != j.
- Similarly, C * D is minimal for all C = at and D = au, with t != u.
If there are multiple solutions, find the lexicographically smallest one (The one with the smallest value of A, and if some of them have equal A then the smallest value of B, etc, etc...).
InputFrom the first line of the standard input read an integer N (4 <= N <= 100 000). From each of the next N read the numbers ai (-1 000 000 <= ai <= 1 000 000).
OutputTo the standard output write the four numbers A B C D separated by space characters.
Input:
Output:
6
5
-2
7
8
2
-1Output:
7 8 -2 8Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.