#P47. [KBC003G] Triangle 2

[KBC003G] Triangle 2

Source

This problem is adapted from Long Long OJ. All rights reserved.

Problem Description

Given nn 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 10410^{-4} 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 nn, with the meaning as described in the problem statement. The second line contains nn floating-point numbers, where the ii-th number aia_i represents the length of the ii-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 10410^{-4}.

If no valid solution exists, output 1-1.

Samples

6
1.123 2.234 3.345 4.456 5.567 6.678
23.403
1
123.456
-1

Data Range

1n2201 \le n \le 2^{20}, 1ai1.875×10121 \le a_i \le 1.875\times10^{12}.