Given up to nine distinct segment lengths, find the largest possible distance from a wall reachable by gluing triangles onto an initial base segment.
Medium6GeometryBacktrackingBrute forceNo attempts yetTime limit2sMemory limit512 MBAlaa remembers a construction toy from her childhood. It was a set of straight segments that could be fastened to each other at their ends. One game she liked started with a single segment laid flat against a straight wall as the base. From there she added triangles one at a time: one side of each new triangle was a segment already in the structure, and the other two sides were two segments she had not used yet. She only built real triangles, so the sum of the lengths of two sides was never equal to the third. No segment could pass through the wall, but a newly added segment could cross segments already in place.
Her goal was to reach as far out from the wall as she could. Building with segments of one single length is dull, so she used sets in which every segment has a different length. She tried different combinations, sometimes using only part of the set and sometimes all of it.
The figures below show a few structures she could build from segments of length 42, 40, 32, 30, 25, 18 and 15. One of them reaches about 66.9495 away from the wall.

Figure: candidate constructions for the lengths above, with the wall at the left of each.
Given the segment lengths, compute the largest distance from the wall that one of Alaa's structures can reach.
The input is a single line of positive integers. The first integer n is the number of segments, with 3≤n≤9. The next n integers l1,l2,…,ln are the segment lengths, with l1>l2>⋯>ln and 1≤lj≤99 for every j. The given lengths always allow at least one triangle.
Print the largest distance from the wall that a structure can reach, with exactly six digits after the decimal point.
Each segment is used at most once, and a structure does not have to use every segment. The input data guarantees that in any structure reaching the maximum distance, every vertex other than the two endpoints of the base segment lies at distance at least 0.0001 from the wall, and that the answer is not ambiguous at the sixth decimal place.