#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 different types of chopsticks, and for each type (), there are exactly chopsticks.
Tonight, guests have arrived, and each guest needs exactly one pair of chopsticks. Since no type of chopstick has at least pieces, Chisato decides to randomly select chopsticks from the full collection, which contains chopsticks in total.
After selecting the 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 and , representing the number of people and the number of the chopstick type, respectively.
The second line contains integers, the -th integer represents the number of chopstick for the -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 (where ). It can be proven that this product is an integer. Output the result modulo .
3 3
2 2 2
0
5 3
3 3 4
1
5 2
8 8
4032
京公网安备 11011102002149号