304458: CF850F. Rainbow Balls
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Rainbow Balls
题意翻译
有一袋 $n$ 个颜色球,第 $i$ 个颜色的球有 $a_i$ 个。 当袋子里至少有两个不同颜色的球时,执行以下步骤: 1. 一个接一个的按照顺序随机取出两个的球,这些球的颜色可能是一样的。 2. 把第二个球涂成第一个球的颜色,然后把两个球放回袋子里。 所有这些动作只需要一秒钟。 输出无法操作时候的期望时间 对 $10^9+7$ 取模 $n\le 2500,1\le a_i \le 10^5$题目描述
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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF850F/2c40be71c60fe708ee9e4e80e2cd7a26163f3bd6.png), where $ P $ and $ Q $ are coprime integers and where $ Q $ is not divisible by $ M $ . Return the value ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF850F/a816c54f8859ee12f4e38a2cc4dba0d6f8dd5c0b.png).输入输出格式
输入格式
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