#Lutece2321. Expected Score
Expected Score
Migrated from Lutece 2321 Expected Score
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Fatdog is playing a game with sequence . On each turn, he needs to choose a position () uniformly at random, replaces the element with , and then removes the element from the sequence. This continues until there is only one element left, which is the score he gets in this round.
Since he will play plenty of rounds with the same sequence, he wants to know the EXPECTED SCORE he will get. But he is too poor at math. Could you help him to calculate it?
EXPECTED SCORE means the mathematical expectation of the score.
Input
The first line of input contains a single integer ().
The second line of input contains integers ().
Output
Print the EXPECTED SCORE. The answer should be rounded to 2 decimal places.
Samples
4
1 1 1 1
0.00
3
1 2 3
-1.00
Note
In the second test case, the sequence is . You have only two ways to operate on the sequence.
- Firstly, replace with () and delete the second element, so the sequence becomes . Secondly, replace with () and delete the second element. So there's only one element left.
- Firstly, replace with () and delete the second element, so the sequence becomes . Secondly, replace with () and delete the second element. So there's only one element left.
Since he choose elements at random, the two situation will happen with same probability . The mathematical expectation is .
Please note that if the answer is , the output should be rather than .
Resources
电子科技大学第十一届 ACM 趣味程序设计竞赛