Swedish coins (2)

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.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:08:27.574Z

© Jutge.org, 2006–2026.
https://jutge.org