In The End

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

There is a board which is infinite in one direction. The board consists of nn rows and an infinite number of columns: there is the first (leftmost) column but no last column. Each column contains exactly one cell with a cake: the probability that the cake is in the ii-th row is p_ip\_i, and all p_ip\_i sum up to 11. Positions of cakes in different columns are independent.

You control a robot which starts in some cell of the first column. On each step, if the robot is at cell (x,y)(x, y) (which means xx-th row and yy-th column), the robot can move to (x,y+1)(x, y + 1), (x1,y+1)(x - 1, y + 1) or (x+1,y+1)(x + 1, y + 1), if such cell exists. Whenever the robot visits a cell with a cake in it, that cake is collected.

The robot wants to collect as many cakes as possible. Given the probabilities p_ip\_i, find the average number of cakes the robot will collect on each step.

Assume that the order of events is as follows. First, all cakes are placed on the board according to the given probabilities. Then, the configuration of the board is given to the robot. After that, the robot chooses a starting cell and a movement plan in order to maximize the average number of collected cakes.

Formally, consider the sequence of boards of sizes n×mn \times m for m=1,2,m = 1, 2, \ldots. For each such finite board, the robot receives the configuration and then chooses an optimal route. Let f(m)f (m) be the expected average number of cakes collected on an n×mn \times m board. Your task is to calculate the limit lim_mf(m)m.\lim\limits\_{m \rightarrow \infty} \frac{f(m)}{m}\text{.}

입력

The first line contains an integer nn (1n61 \le n \le 6), the number of rows.

The next line contains nn real numbers p_ip\_i (0p_i10 \le p\_i \le 1) given with at most one digit after the decimal point: the probability distribution.

출력

It can be proven that the answer to the problem can be expressed as a fraction PQ\frac{P}{Q} for some positive integers PP and QQ. Find such PP and QQ, and print the number (PQ1)mod(109+7)(P \cdot Q^{-1}) \bmod (10^9 + 7).