(Over)due Diligence


Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python

You've found yourself in a bit of a rut, with many overdue assignments!

To fix this, you've created a list of all of the assignments you need to do, as well as an estimate for the amount of time in hours it will take to do each one.

The overdue penalty system is based on how long it has been since the due date, with a longer period resulting in higher grade deduction.

Can you figure out an order to do your assignments in to cause the least amount of total overdue hours for all of your assignments?

Input

The first line consists of an integer n (1 \leq n \leq 100), the number of assignments you have overdue.

The next n lines each consist of a single integer m_i (1 \leq m_i \leq 100), the estimated amount of hours it will take to do the ith assignment.

Output

Output a single integer, the minimum amount of overdue hours that you can achieve after doing all of the overdue assignments.

Example

Input
3
4
10
4
Output
30

We can first do one of the 4-hour assignments and then submit it, adding 4 hours to our total overdue hours.

We can then do the other 4-hour assignment. Since we already took 4 hours on the first assignment, after doing this one it will have been overdue for 8 hours.

We then do the last assignment, which takes 10 hours. Since the previous assignments took a total of 8 hours, after doing this one it will have been overdue for 18 hours.

This gives us a total of 4 + 8 + 18 = 30 hours. It can be shown that this is the minimum possible amount.


Comments

There are no comments at the moment.