Hide

Problem B
Black and White

Black and White is a Chinese children’s game played in rounds. During each round, the children who are playing all put their hands in either face-up (“White”) or face-down (“Black”). If all the children but one make the same choice, then the “odd one out” sits out for the rest of the game. Play continues until there are only two children left.

Each child independently chooses whether to put their hand face-up with their own fixed probability. What is the expected number of rounds that such a game will last?

Input

The first line contains a single integer $n$ ($2 \le n \le 20$), which is the number of children.

Each of the next $n$ lines contains a single real number $p$ ($0.1 \le p \le 0.9$). These are the probabilities for each child that they will put their hand in face-up. The probabilities will have at most three digits after the decimal point.

Output

Output a single real number, which is the expected number of rounds. The result must be accurate to within an absolute or relative error of $10^{-6}$.

Sample Input 1 Sample Output 1
3
0.5
0.5
0.5
1.3333333
Sample Input 2 Sample Output 2
3
0.3
0.3
0.3
1.5873015
Sample Input 3 Sample Output 3
5
0.1
0.3
0.5
0.7
0.9
7.4752846

Please log in to submit a solution to this problem

Log in