This page is still under construction.

Parts of this page are still being built. What you see may change.

Wandering

Time limit1sMemory limit256 MB

Summary
Given n radii, compute the expected squared distance from the origin after n independent uniform steps inside disks of those radii.
Level

Medium4 of 10

Topics
Probability, Math, Geometry, Implementation
Solved
No attempts yet

Problem

Rikka is a talented student.

She likes to wander in the corridor while solving ICPC problems. Specifically, she takes a random walk of nn steps. In the ii-th random step, she chooses one of the vectors (x,y)(x, y) such that x,y∈Rx, y \in \mathbb{R} and x2+y2≤Ri2x^2 + y^2 \le R_i^2 with equal probability. Then she walks along that vector. In other words, if she stood at (A,B)(A, B) before the random step, she stands at (A+x,B+y)(A + x, B + y) afterwards. Before wandering, she stands at the door (0,0)(0, 0).

After wandering, she became curious about the expected value of the square of the Euclidean distance to the point (0,0)(0, 0). In other words, if she stands at (x,y)(x, y) after all nn random steps, she wants to know the expected value of x2+y2x^2 + y^2.

Input

The first line contains an integer nn, the number of random steps.

The second line contains nn positive integers RiR_i, the parameter of the ii-th random step.

It is guaranteed that 1≤n≤50 0001 \le n \le 50\,000 and 1≤Ri≤10001 \le R_i \le 1000.

Output

You must output dd, the expected value of x2+y2x^2 + y^2. Letting the correct answer be d∗d^*, you must ensure that ∣d−d∗∣max⁡{d∗,1}≤10−6\frac{|d - d^*|}{\max\{d^*, 1\}} \leq 10^{-6}.

Examples1

  1. Example 1

    Input
    3
    1 2 3
    
    Expected output
    7.000000000000000