5330: Sample Game

内存限制:512 MB 时间限制:2.000 S
评测方式:文本比较 命题人:
提交:0 解决:0

题目描述

Bob has a random number generator, it will generate x with probability px.
Now Bob will do the following operations:
  • Step 1. Generate a number x by random number generator. 
  • Step 2. If x is the largest number among the generated numbers (i.e.  x is no smaller than any previously generated numbers), go to step 1, otherwise, go to step 3. 
  • Step 3. If Bob generates x numbers totally, Bob will get x2 score. 
Now Bob wants to know the expected value of the score he will get.
If the answer is irreducible fraction x/y, you need to output an integer d in [0,998244352] which satisfies d * y mod 998244353=x mod 998244353.
It's guaranteed that y mod 998244353≠0.

输入

The first line has one integers n, it means the random number generator can only generate integers in [1,n].
The second line has n positive integers w1...n, it means pi = w/(∑j=1 wj).
2≤n≤100,1≤wi≤106.

输出

Output the answer.

样例输入 复制

3
1 1 1

样例输出 复制

499122190