AT_abc412_f [ABC412F] Socks 4

Description

In Takahashi's chest of drawers, there are socks of $ N $ colors, with $ A_i $ socks of color $ i $ . Initially, Takahashi has one sock of color $ C $ outside the chest of drawers, separate from these socks, and repeats the following operation until the termination condition is met: - Uniformly randomly choose and draw $ 1 $ sock from the chest of drawers. Then, if the two socks he has outside the chest of drawers are the same color, terminate the operation. Otherwise, choose one of the socks and put it back in the chest of drawers. He always chooses the sock to put back so as to minimize the expected number of future sock draws. Find the expected number, modulo $ 998244353 $ , of sock draws until the operation terminates. Finding the expected value modulo $ 998244353 $ Under the constraints of this problem, it can be proved that the expected value exists and is a rational number. It can also be proved that when this value is expressed as an irreducible fraction $ \frac{P}{Q} (Q > 0) $ , we have $ Q \not\equiv 0 \pmod{998244353} $ . Therefore, there uniquely exists an integer $ R $ satisfying $ R \times Q \equiv P \pmod{998244353}, 0 \leq R < 998244353 $ . Finding the expected value modulo $ 998244353 $ means finding this value of $ R $ .

Input Format

The input is given from Standard Input in the following format: > $ N $ $ C $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $

Output Format

Output the answer.

Explanation/Hint

### Sample Explanation 1 The expected number of sock draws is $ \frac{15}{4} $ . ### Constraints - $ 1 \leq N \leq 3 \times 10^5 $ - $ 1 \leq C \leq N $ - $ 1 \leq A_i \leq 3000 $ - All input values are integers.