Circles tangent to a line

Arrange N given circles on one side of a line, each touching it, without interiors overlapping, and minimize the span between the leftmost and rightmost touch points.

Medium6Brute forceGeometrySortingNo attempts yetTime limit2sMemory limit512 MB

Problem

You are given NN circles with fixed radii and one straight line. Place every circle on the same side of the line so that it touches the line. The interiors of two different circles must not overlap, but two circles may meet at a single point.

In such a placement each circle touches the line at exactly one point. Write a program that finds the smallest possible distance between the touching point of the leftmost circle and the touching point of the rightmost circle.

Input

The first line contains the number of circles NN (2N82 \le N \le 8).

The second line contains the NN radii separated by spaces. Every radius is an integer between 1 and 1,000,000,000.

Output

Print the smallest possible distance on the first line, rounded at the seventh digit after the decimal point. Always print exactly six digits after the decimal point. For example, a value of exactly 28 is printed as 28.000000.