~/algor $ cat problems/ochkoz-tayoqchalar-uchburchak
Triangle from sticks
Easy
1000 ms
128 MB
33%
$n$ sticks are given, the length of the $i$-th one is $a_{i}$. Choose three of them and form a triangle of positive area (the sticks cannot be broken). Among all such triangles, print the largest perimeter. If no triangle can be formed, print $0$.
Input
The first line contains a positive integer $n$. The second line contains $n$ space-separated positive integers $a_{i}$.
Output
One integer — the largest perimeter or $0$.
Note
$3 \le n \le 10^{5}$
$1 \le a_{i} \le 10^{9}$
Examples
Input #1
6 2 3 9 4 15 5
Output #1
12
Input #2
4 1 2 3 6
Output #2
0