Time limit
2s
Memory limit
128 MB
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.
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.
Print the maximum possible sum of triangle areas on the first line. An absolute or relative error up to 10^-9 is allowed.
For three lengths A, B, and C with A≤B≤C, a triangle can be made only when A+B>C. Its area is p(p−A)(p−B)(p−C), where p=(A+B+C)/2.