LogiQuest

460. Largest Perimeter Triangle

EasySortingGreedy

Print the largest perimeter of a triangle with non-zero area formed from three of the lengths, or 0.

Input format

Line 1: n Line 2: n lengths

Output format

The largest perimeter.

Example 1

Input

3
2 1 2

Output

5

Example 2

Input

3
1 2 1

Output

0

Constraints

3 ≤ n ≤ 10⁴

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…