~/algor $ cat problems/minmax-37-uchta-eng-katta-yigindisi
Sum of the three largest numbers
Medium
1000 ms
128 MB
53%
A positive integer $N$ and $N$ integers are given. Choose three elements at different positions of the sequence so that their sum is the largest. Find this sum.
Input
The first line contains a positive integer $N$. The next line contains $N$ integers $A_{i}$.
Output
One integer.
Note
$3 \le N \le 10^{5}$
$-10^{9} \le A_{i} \le 10^{9}$
Examples
Input #1
6 4 9 1 7 9 3
Output #1
25
Input #2
3 -2 -5 -1
Output #2
-8