题库练习 Rainbow Balls
← 上一题 下一题 →

A11074 | Rainbow Balls

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You have a bag of balls of $n$ different colors. You have $a_{i}$ balls of the $i$ -th color.

While there are at least two different colored balls in the bag, perform the following steps:

- Take out two random balls without replacement one by one. These balls might be the same color.
- Color the second ball to the color of the first ball. You are not allowed to switch the order of the balls in this step.
- Place both balls back in the bag.
- All these actions take exactly one second.

Let $M=10^{9}+7$ . It can be proven that the expected amount of time needed before you stop can be represented as a rational number ![](/uploads/luogu/CF850F/2c40be71c60fe708ee9e4e80e2cd7a26163f3bd6_735a0002cdb6.png), where $P$ and $Q$ are coprime integers and where $Q$ is not divisible by $M$ . Return the value ![](/uploads/acgo/image/4f8d1b7b81ef742d_3cb07ddfbea2.jpeg).

输入格式

The first line of input will contain a single integer $n$ ( $1<=n<=2500$ ) — the number of colors.

The next line of input will contain $n$ space separated integers $a_{1},a_{2},...,a_{n}$ ( $1<=a_{i}<=10^{5}$ ) — the number of balls of each color.

输出格式

Print a single integer, the answer to the problem.

输入输出样例

输入 #1
2
1 1
输出 #1
1
输入 #2
3
1 2 3
输出 #2
750000026
C++ 编辑器
输入
输出