Mock CCC '23 2 S2 - Keenan Hates Triangles
View as PDFKeenan got sticks for his birthday! As part of his birthday present, he tries to make two triangles out of them!
In order for three sticks with lengths ,
, and
to form a triangle, it must be the case that
,
, and
.
Keenan wants to maximize the sum of the perimeters of the two triangles he makes. Help him compute this! Note that a stick cannot be used in both triangles.
Constraints
Input Specification
The first line contains one integer, .
Each of the next lines contains one integer,
.
Output Specification
Output the maximum possible sum of the perimeters of the two triangles Keenan makes. If Keenan cannot make two triangles, output 0.
Sample Input
6
1
1
1
1
1
1
Sample Output
6
Comments