Sample Game
题号:NC224145
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Bob has a random number generator, it will generate with probability p_x

Now Bob will do the following operations:

Step 1. Generate a number by random number generator.

Step 2. If is the largest number among the generated numbers (i.e., is no smaller than any previously generated numbers), go to step 1, otherwise, go to step 3.

Step 3. If Bob generates numbers totally, Bob will get score.

Now Bob wants to know the expected value of the score he will get.

If the answer is irreducible fraction , you need to output an integer in [0,998244352] which satisfies . It's guaranteed that .

输入描述:

The first line has one integers , it means the random number generator can only generate integers in .

The second line has positive integers , it means .

.

.

输出描述:

Output the answer.
示例1

输入

复制
3
1 1 1

输出

复制
499122190