Let $N$ be a positive odd number. There are $N$ coins, numbered $1,2,\dots,N$. For each $i$ $(1≤i≤N)$, when Coin $i$ is tossed, it comes up heads with probability $p_i$ and tails with probability $1−p_i$. Alice has tossed all the $N$ coins. Find the probability of having more heads than tails.
Input
The first line of input contains an integer $N$. The second line of input contains $N$ real numbers with 2 decimal places $p_1, p_2, \dots, p_N$.
Output
Output a single real number denoting the required probability. Your answer is considered correct if its absolute or relative error doesn't exceed $10^{-6}$. Namely, if your answer is $a$, and the jury's answer is $b$, then your answer is accepted, if $\frac{|a-b|}{\max(1,|b|)} \le 10^{-6}$.
Constraints
$1 \le N \le 2999$
$0 \lt p_i \lt 1$
Sample Test Cases
Input | Output | |
---|---|---|
3 0.30 0.60 0.80 |
0.612 | |
1 0.50 |
0.5 | |
5 0.42 0.01 0.42 0.99 0.42 |
0.3821815872 |
Scoring: Per Subtask
Authored by s17r28
Appeared in 2023 DP Contest