#P15900. [TOPC 2025] Chopsticks

[TOPC 2025] Chopsticks

Description

Chisato works at a traditional Japanese restaurant that just received a shipment of beautifully handcrafted chopsticks. There are mm different types of chopsticks, and for each type ii (1im1 \le i \le m), there are exactly kik_i chopsticks.

Tonight, nn guests have arrived, and each guest needs exactly one pair of chopsticks. Since no type of chopstick has at least 2n2n pieces, Chisato decides to randomly select 2n2n chopsticks from the full collection, which contains s=i=1mkis = \sum_{i=1}^{m} k_i chopsticks in total.

After selecting the 2n2n chopsticks, Chisato will try to distribute them in a way that maximizes the number of guests receiving a matching pair, that is, two chopsticks of the same type. If it’s not possible to provide matching pairs for everyone, some guests will receive mismatched pairs.

Your task is to compute the expected number of guests who receive mismatched pairs of chopsticks under this strategy.

Input Format

The first line contains two integers nn and mm, representing the number of people and the number of the chopstick type, respectively.

The second line contains mm integers, the ii-th integer kik_i represents the number of chopstick for the ii-th type.

Output Format

Print a single integer, the expected number of people who cannot get a pair of chopsticks of the same type, multiplied by (s2n)\binom{s}{2n} (where s=i=1mkis = \sum_{i=1}^{m} k_i). It can be proven that this product is an integer. Output the result modulo 998244353998244353.

3 3
2 2 2
0
5 3
3 3 4
1
5 2
8 8
4032

Hint

  • 1n2.5×1051 \le n \le 2.5 \times 10^5
  • 1m5×1051 \le m \le 5 \times 10^5
  • 1ki<2×n1 \le k_i < 2 \times n
  • 2×ns2 \times n \le s