Under construction

Still being built. Things may change

Colonization

Time limit1sMemory limit1024 MB

Summary
Given N circles that must all touch each other externally, find the enclosed base area, or for N=3 the radius of a fourth circle that touches all three.
Level

Medium5 of 10

Topics
Geometry, Math
Solved
No attempts yet

Statement

Long ago, in a distant galaxy, one faraway planet became too crowded, so its people decided to start colonizing. Without much deliberation, they chose the closest natural satellite as their first target: the Moon.

Huge shuttles brought NN autonomous modules to the Moon, where people would live. Each module is a bionic glass dome shaped like a circle with radius RiR_i. It turned out the modules were not fully autonomous, so they had to be connected with passages. A passage can be built only when two domes stand flush against each other, that is, when their bounding circles touch externally.

The settlers want to build a lunar base. They must arrange the modules so that every pair of domes has a passage between them, and then compute the area of the resulting base. The area of the base includes not only the area under the modules but also the region that cannot be entered without passing through a dome.

The figure shows the modules as circles, the base area in gray, the passages as blue segments, and the new module to be added in red.

The settlement went on for many years. Then the Moon ran short of room, as the old planet had. The people decided to extend the bases. For a base made of three modules, they add a fourth module if it is small enough to fit between the other three. The new module must stand flush against all three, so new passages can be built. To manufacture it at the M-factory, they need the radius of this fourth dome.

Input

The first line contains NN, the number of domes (1≤N≤10001 \le N \le 1000). The next line contains NN integers, the dome radii. Each radius is a positive integer not exceeding 1000. When N=3N = 3, the last line may also contain the word 'INSERT'.

Output

If the base cannot be built as required, print −1-1. Otherwise, print the area of the base. If N=3N = 3 and the last input line contained 'INSERT', print the radius of the fourth dome on the next line. An answer is accepted if its absolute or relative error does not exceed 10−610^{-6}.

Examples3

  1. Example 1

    Input
    3
    1 2 3
    
    Expected output
    44.4465535613
    
  2. Example 2

    Input
    4
    12 1 12 3
    
    Expected output
    940.0432014879
    
  3. Example 3

    Input
    3
    2 8 8
    INSERT
    
    Expected output
    417.7969784391
    0.6666666667