Skip to main content
LIVE CONTEST: Round #7 · Begin Marathon is live now! …

~/algor $ cat problems/minmax/sum-of-the-three-largest-numbers

Sum of the three largest numbers

Author Iqbolshoh Ilhomjonov 3 @iqbolshoh 650 problems
Medium 1000 ms 128 MB 53%
Share

A positive integer and integers are given. Choose three elements at different positions of the sequence so that their sum is the largest. Find this sum.

Choosing three elements of the sequence with the largest sum

Input

The first line contains a positive integer . The next line contains integers .

Output

One integer.

Note


Examples

Input #1
6
4 9 1 7 9 3
Output #1
25
Input #2
3
-2 -5 -1
Output #2
-8

Sign in to submit a solution

Signing up is free and takes a minute.