Swedish coins (2) P20294


Statement
 

pdf   zip

The statement of this problem is similar to the previous one. But here, you must solve a different problem:

Given a collection of coins CC, how many subsets SS of CC are such that w(S)=1/2w(S) = 1/2?

Input

Input consists of several cases, each one with nn followed by p1pnp_1 \dots p_n. Assume 1n1051 \le n \le 10^5 and 0<pi<10 < p_i < 1.

Output

For every case, print the number of subsets SS such that w(S)=1/2w(S) = 1/2. Since this number can be huge, compute it modulo 108+710^8 + 7.

Public test cases
  • Input

    1  0.3
    5  0.5 0.5 0.5 0.5 0.5
    

    Output

    0
    31
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++