Under construction

Still being built. Things may change

In the End

Time limit2sMemory limit512 MB

Summary
Each column holds one cake at a random row, and the robot moves right with a row change of at most 1; find the limit of f(m)/m modulo 1e9+7.
Level

Hard9 of 10

Topics
Probability, Dynamic programming, Math
Solved
No attempts yet

Problem

The board is infinite in one direction. It has nn rows and an infinite number of columns, with a first (leftmost) column but no last column. Each column contains exactly one cell with a cake. The cake is in row ii with probability pip_i, and all pip_i sum to 11. Cake positions in different columns are independent. A robot starts in some cell of the first column. If the robot is at cell (x,y)(x, y) (row xx, column yy), in one step it can move to (x,y+1)(x, y + 1), (x−1,y+1)(x - 1, y + 1), or (x+1,y+1)(x + 1, y + 1), whenever that cell exists. When the robot visits a cell with a cake, it collects that cake. The order of events is as follows: first all cakes are placed according to the given probabilities, then the configuration is given to the robot, and then the robot chooses a starting cell and a movement plan to maximize the number of cakes it collects. For each board of size n×mn \times m with m=1,2,…m = 1, 2, \ldots, let f(m)f(m) be the expected average number of cakes collected per step under an optimal route. Compute lim⁡m→∞f(m)m\lim_{m \rightarrow \infty} \frac{f(m)}{m}.

Input

The first line contains an integer nn (1≤n≤61 \le n \le 6), the number of rows. The next line contains nn real numbers pip_i (0≤pi≤10 \le p_i \le 1) with at most one digit after the decimal point. Their sum is 11.

Output

The answer can be written as a fraction PQ\frac{P}{Q} with positive integers PP and QQ. Print (P⋅Q−1) mod (109+7)(P \cdot Q^{-1}) \bmod (10^9 + 7).

Examples3

  1. Example 1

    Input
    2
    0.5 0.5
    
    Expected output
    1
    
  2. Example 2

    Input
    3
    0.3 0.3 0.4
    
    Expected output
    804545461
    
  3. Example 3

    Input
    4
    0.2 0.3 0.2 0.3
    
    Expected output
    84928504