提示: 欢迎访问OurACM平台。
Problem 1614 Hero's time

Accept: 206    Submit: 507
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

As the old saying goes:

To Realize The Value of Time

To realize the value of ONE YEAR
ask the student who has failed a class
To realize the value of ONE MONTH
ask a mother who gave birth to a premature baby
To realize the value of ONE WEEK
ask the editor of a weekly newspaper
To realize the value of ONE HOUR
ask the lovers who are waiting to meet
To realize the value of ONE MINUTE
ask a person who missed the train
To realize the value of ONE SECOND
ask a person who just avoided accident
To realize the value of ONE MILLISECOND
ask the person who won a silver medel in the Olympics
Treasure every moment that you have!
Yesterday is history.
Tomorrow is mystery.
Today is a gift.
That's why it is called present!
Show your friends how much you care...

To be hero, time is very important. In the International Collegiate Programming Contest(ICPC), the victory of success is half won when one knows how to select the proper order to solve them. Time to solve a problem is calculated from the begining of the contest to the submiting juncture. Hero's mission is minimizing the total time of solving all the problem.

Input

There are multiply testcases. In each testcase, the first line contains an integer n (0<=n<=10000), denotes the number of the problem, the next line contains n integers X1,X2,...,Xn, Xi denotes the minutes you need to solved ith problems [1..300].

Output

For each teatcase, output one line contains an integer which denotes the minimal total time.

Sample Input

4 10 10 30 20

Sample Output

140

Source

FOJ月赛-2008年6月 -- Heroes Happen Here

Submit  Back  Status  Discuss