ATM

No attempts yetTime limit1sMemory limit256 MB

Problem

Inha Bank has only one ATM. Right now NN people are standing in line in front of it. The people are numbered 1 through NN, and person ii needs PiP_i minutes to withdraw money.

A person can start only after everyone ahead of them has finished, so the time a person needs to finish withdrawing is the sum of the withdrawal times of everyone ahead plus their own. The total of those finish times therefore depends on the order of the line.

For example, take 5 people with P1=3P_1 = 3, P2=1P_2 = 1, P3=4P_3 = 4, P4=3P_4 = 3, P5=2P_5 = 2. In the order 1, 2, 3, 4, 5, person 1 takes 3 minutes, person 2 takes 3+1=43+1=4 minutes, person 3 takes 3+1+4=83+1+4=8 minutes, person 4 takes 3+1+4+3=113+1+4+3=11 minutes, and person 5 takes 3+1+4+3+2=133+1+4+3+2=13 minutes, for a total of 3+4+8+11+13=393+4+8+11+13=39 minutes. In the order 2, 5, 1, 4, 3 the finish times are 1, 3, 6, 9, and 13 minutes, for a total of 32 minutes, and no order gives a smaller total.

Given the number of people NN and the withdrawal time PiP_i of every person, write a program that finds the smallest possible sum of the times the people need to withdraw money.

Input

The first line contains the number of people NN (1N10001 \le N \le 1000).

The second line contains the withdrawal times P1,P2,,PNP_1, P_2, \dots, P_N, separated by spaces (1Pi10001 \le P_i \le 1000).

Output

Print the smallest possible sum of the times the people need to withdraw money on the first line.