#P7840. 「C.E.L.U-03」重构
「C.E.L.U-03」重构
Background
Luo Siji recently found that the server runs very slowly, so he plans to reconstruct the entire server network to improve efficiency.
Problem Description
Luo Siji has servers, and each server has a busyness value . Luo Siji will connect them together using network links, so each server will have a degree , which is the number of connected links. The total running time of this server network is . Please minimize this value.
Input Format
The first line contains one integer, .
The second line contains integers, where the -th integer represents .
Output Format
The first line contains one integer, the answer.
4
2 3 4 4
28
Hint
Sample Explanation:
Connect three edges . The degrees are , respectively.
| Testdata ID | Special Property | |
|---|---|---|
| None | ||
| All are equal | ||
| None | ||
Constraints: For of the testdata, and .
Translated by ChatGPT 5