Problem:
Problem J: Cheating on ICPC

Peter loves any kinds of cheating. A week before ICPC, he broke into Doctor's PC and sneaked a look at all the problems that would be given in ICPC. He solved the problems, printed programs out, and brought into ICPC. Since electronic preparation is strictly prohibited, he had to type these programs again during the contest.

Although he believes that he can solve every problems thanks to carefully debugged programs, he still has to find an optimal strategy to make certain of his victory.

Teams are ranked by following rules.

Team that solved more problems is ranked higher.

In case of tie (solved same number of problems), team that received less Penalty is ranked higher.

Here, Penalty is calculated by these rules.

When the team solves a problem, time that the team spent to solve it (i.e. (time of submission) - (time of beginning of the contest)) are added to penalty.

For each submittion that doesn't solve a problem, 20 minutes of Penalty are added. However, if the problem wasn't solved eventually, Penalty for it is not added.

You must find that order of solving will affect result of contest. For example, there are three problem named A, B, and C, which takes 10 minutes, 20 minutes, and 30 minutes to solve, respectively. If you solve A, B, and C in this order, Penalty will be 10 + 30 + 60 = 100 minutes. However, If you do in reverse order, 30 + 50 + 60 = 140 minutes of Penalty will be given.

Peter can easily estimate time to need to solve each problem (actually it depends only on length of his program.) You, Peter's teammate, are asked to calculate minimal possible Penalty when he solve all the problems.

Input

Input file consists of multiple datasets. The first line of a dataset is non-negative integer N (0 ≤ N ≤ 100) which stands for number of problem. Next N Integers P[1], P[2], ..., P[N] (0 ≤ P[i] ≤ 10800) represents time to solve problems.

Input ends with EOF. The number of datasets is less than or equal to 100.

Output

Output minimal possible Penalty, one line for one dataset.

Sample Input

3
10 20 30
7
56 26 62 43 25 80 7

Output for the Sample Input

100
873

Solution in Ruby (judge verdict: Accepted)

while gets
  n=$_.to_i
  if n==0
    puts 0
    next
  end
  ts = gets.split.map(&:to_i)
  ts.sort!
  ps = (0..n-1).inject([0]){|seq,i| seq<<(seq[i]+ts[i])}
  total = ps.inject{|x,y| x+y}
  puts total
end