Introduction - If you have any usage issues, please Google them yourself
Programming combines fruit
For example, there are 3 kinds of fruit, the number is 1, 2, 9. The merger scheme is as follows:
1. combined 1 and 2, the new heap number is 3, and the physical strength is 3.
2. combine the new heap with the third heap, and get the new heap, the number is 12, the energy consumption is 12.
3. of the total physical exertion was 3 + 12 = 15, and 15 could be proved to be the minimum physical exertion value.
input
The input consists of two rows, and the first line is an integer n (1< = n<=10000) indicating the number of fruits. The second line contains n integers, separated by spaces. The first I integer AI (1< = ai<=10000) is the number of the first I species.