#P5644. [PKUWC2018] 猎人杀

[PKUWC2018] 猎人杀

Description

Hunter Kill is a folk version of the once-popular game “Werewolf”. The rules are as follows.

At the beginning, there are nn hunters. The ii-th hunter has a hatred value wiw_i. Each hunter has only one fixed skill: after dying, they must fire one shot, and the person who is shot will also die.

However, choosing whom to shoot is also important. Suppose the hunters still alive are [i1im][i_1\ldots i_m]. Then the probability of shooting hunter iki_k is wikj=1mwij\frac{w_{i_k}}{\sum_{j = 1}^{m} w_{i_j}}.

At the beginning, the first shot is fired by you, and the target is chosen in the same way as the hunters (that is, hunter ii is hit with probability wij=1nwj\frac{w_i}{\sum_{j=1}^{n}w_j}). Due to the chain reaction caused by shooting, all hunters will eventually die. Now hunter 11 wants to know the probability that they are the last one to die.

Output the answer modulo 998244353998244353.

Input Format

The first line contains a positive integer nn.

The second line contains nn positive integers. The ii-th positive integer denotes wiw_i.

Output Format

Output the answer.

3
1 1 2
915057324

Hint

Sample Explanation

The answer is $\frac{2}{4}\times \frac{1}{2}+\frac{1}{4}\times \frac{2}{3}=\frac{10}{24}$.

For 10%10\% of the testdata, 1n101\leq n\leq 10.

For 30%30\% of the testdata, 1n201\leq n\leq 20.

For 50%50\% of the testdata, 1i=1nwi50001\leq \sum\limits_{i=1}^{n}w_i\leq 5000.

For another 10%10\% of the testdata, 1wi21\leq w_i\leq 2, and w1=1w_1=1.

For another 10%10\% of the testdata, 1wi21\leq w_i\leq 2, and w1=2w_1=2.

For 100%100\% of the testdata, wi>0w_i>0, and 1i=1nwi1000001\leq \sum\limits_{i=1}^{n}w_i \leq 100000.

Translated by ChatGPT 5