#P9894. Coins
Coins
Coins
Problem Description
There are people playing a game, where th person has coins. In each round, they randomly choose two players. Then the first one should give one coin to the second. If someone leaves no coin after that, he leaves the game and the rest players continue the game until a player owns all the coins. Foreverlasting wants to know the expected number of rounds.
Input
The first line contains integer --- the number of test cases. For each of the next test cases, the format is: The first line contains an integer , representing the number of people. The next line contains integers , representing the number of coins that each person has. (请不要使用 scanf 进行读入)
Output
For each case, output the expected number of rounds. The answer is guaranteed to be an integer.
Sample Input
1
3
1 1 1
Sample Output
3
Source
2023“钉耙编程”中国大学生算法设计超级联赛(9)