Under construction

Still being built. Things may change

Black and White

Time limit2sMemory limit1024 MB

Summary
Given each child's fixed probability of choosing white, find the expected number of rounds until an elimination game leaves two children.
Level

Medium7 of 10

Topics
Probability, Dynamic programming, Combinatorics, Math
Solved
No attempts yet

Problem

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 nn (2≤n≤202 \le n \le 20), which is the number of children.

Each of the next nn lines contains a single real number pp (0.1≤p≤0.90.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−610^{-6}.

Examples3

  1. Example 1

    Input
    3
    0.5
    0.5
    0.5
    
    Expected output
    1.3333333
    
  2. Example 2

    Input
    3
    0.3
    0.3
    0.3
    
    Expected output
    1.5873015
    
  3. Example 3

    Input
    5
    0.1
    0.3
    0.5
    0.7
    0.9
    
    Expected output
    7.4752846