#P47. [KBC003G] Triangle 2
[KBC003G] Triangle 2
Source
This problem is adapted from Long Long OJ. All rights reserved.
Problem Description
Given sticks, select 3 of them to form a triangle, then select another 3 distinct sticks to form a second triangle. Find the maximum sum of the perimeters of these two triangles.
It is guaranteed that a calculation error within will not lead to a wrong answer.
Three sticks can only form a triangle if they are connected end to end in sequence.
For a valid triangle, the sum of the lengths of any two sides must be greater than the length of the third side.
Input Format
The first line contains a positive integer , representing the numbers of sticks.
The second line contains floating-point numbers $a_1, a_2, \ldots, a_n\ \ (1 \le a_i \le 1.875 \times 10^{12})$, representing the lengths of the sticks.
Output Format
Output a single floating-point number, representing the maximum sum of the perimeters of the two triangles.
Your answer must have an absolute or relative error within .
If no valid solution exists, output .
Samples
6
1.123 2.234 3.345 4.456 5.567 6.678
23.403
1
123.456
-1