#P8236. [AGM 2022 资格赛] 魔法的力量

[AGM 2022 资格赛] 魔法的力量

Problem Description

You have nn piles of stones. The ii-th pile contains aia_i stones. You will perform n1n-1 operations. In each operation, you may choose two piles and merge them into one pile. The score gained is the sum of the sizes of the two chosen piles.

Now, if in each operation you randomly choose two piles to merge, what is the expected total score?

Input Format

The first line contains a positive integer nn.

The next line contains nn numbers aia_i.

Output Format

Output one real number in a single line, representing the answer.

An answer with an error not exceeding 10610^{-6} will be considered correct.

5
3 1 2 6 3
38.5000000000

Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that 2n5002 \le n \le 500 and 1ai1091 \le a_i \le 10^9.

Notes

Translated from AGM 2022 Qualification Round H Magic Powers

Translated by ChatGPT 5