FIICode 2024 Open | Losing Streak

This was the problem page during the contest. Access the current page here.
Time limit: 3s Memory limit: 1024MB Input: Output:

NUME\mathbb{NUME} is a big fan of the popular MOBA League of Legends. He just got off work and plans to play nn games of LOL. The only problem is that he is afraid of losing streaks. He knows that if he loses too many games in a row, his night will be ruined. Fortunately, by methods only known to him, he knows for each game what is the chance that he will lose it. Given this information, he wants to know what is the expected value of the length of the longest losing streak during those nn games. The answer should be given modulo 109+710^9 + 7.

Input

The first line contains an integer nn (1n50001 \le n \le 5\,000) – the number of games that NUME\mathbb{NUME} will play.

The second line contains nn integers pip_i (0pi1000 \le p_i \le 100) – the percent probability that NUME\mathbb{NUME} will lose the ii-th game.

Output

You should output one number – the expected value of the length of the longest losing streak modulo 109+710^9 + 7.

Example 1

stdin

2
50 50

stdout

1

Example 2

stdin

9
50 3 19 83 24 24 94 26 83

stdout

575309567

Notes

In the first example we have a 50%50\% chance of losing each game. Therefore, we have a 1/41 / 4 chance of losing both games, 1/21 / 2 chance of winning only one game, and 1/41 / 4 of winning both games.

So in the end the answer is 0(1/4)+1(1/2)+2(1/4)=10 \cdot (1 / 4) + 1 \cdot (1 / 2) + 2 \cdot (1 / 4) = 1.

Contest info

Official contest

Start time: 1710082800000

Total duration: 2h30m0s

Status: Ended

Log in or sign up to be able to send submissions!