#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.
Note 1: Three sticks can only form a triangle if they are connected end to end in sequence. Note 2: 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 an integer , with the meaning as described in the problem statement. The second line contains floating-point numbers, where the -th number represents the length of the -th stick.
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
Data Range
, .