cho.sh
Notes
Loading...

Fences

Time limit

2s

Memory limit

128 MB

Problem

You have N fences with fixed lengths on a wide field. By choosing three distinct fences, you can make one triangular fence; each side of the triangle is one fence. Fences cannot be joined or cut, and a fence used in one triangle cannot be used again in another triangle.

Choose the triangles to build so that the sum of their areas is as large as possible. Compute the maximum possible total area.

Input

The first line contains the number of fences N. N is a positive integer not greater than 16.

The second line contains the length of each fence. Each length is a positive integer not greater than 100.

Output

Print the maximum possible sum of triangle areas on the first line. An absolute or relative error up to 10^-9 is allowed.

Hint

For three lengths AAA, BBB, and CCC with A≤B≤CA \le B \le CA≤B≤C, a triangle can be made only when A+B>CA+B>CA+B>C. Its area is p(p−A)(p−B)(p−C)\sqrt{p(p-A)(p-B)(p-C)}p(p−A)(p−B)(p−C)​, where p=(A+B+C)/2p=(A+B+C)/2p=(A+B+C)/2.