Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks:

  * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. Then he gives the group to the Appleman. 
  * Each time Appleman gets a group consisting of a single number, he throws this group out. Each time Appleman gets a group consisting of more than one number, he splits the group into two non-empty groups (he can do it in any way) and gives each of them to Toastman. 



After guys complete all the tasks they look at the score value. What is the maximum possible value of score they can get?

Input

The first line contains a single integer n (1 ≤ n ≤ 3·105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106) — the initial group that is given to Toastman.

Output

Print a single integer — the largest possible score.

Examples

Input

3
3 1 5


Output

26


Input

1
10


Output

10

Note

Consider the following situation in the first example. Initially Toastman gets group [3, 1, 5] and adds 9 to the score, then he give the group to Appleman. Appleman splits group [3, 1, 5] into two groups: [3, 5] and [1]. Both of them should be given to Toastman. When Toastman receives group [1], he adds 1 to score and gives the group to Appleman (he will throw it out). When Toastman receives group [3, 5], he adds 8 to the score and gives the group to Appleman. Appleman splits [3, 5] in the only possible way: [5] and [3]. Then he gives both groups to Toastman. When Toastman receives [5], he adds 5 to the score and gives the group to Appleman (he will throws it out). When Toastman receives [3], he adds 3 to the score and gives the group to Appleman (he will throws it out). Finally Toastman have added 9 + 1 + 8 + 5 + 3 = 26 to the score. This is the optimal sequence of actions.
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.util.regex.*;
public final class Main{
	static StringTokenizer st;
	static PrintWriter pw = new PrintWriter(System.out,true);
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	private static String next()throws Exception{
		if(st == null || !st.hasMoreTokens()){
			st = new StringTokenizer(br.readLine()," ");
		}
		return st.nextToken();
	}
	private static char nc()throws Exception{
		return next().charAt(0);
	}
	private static int ni()throws Exception{
		return Integer.parseInt(next());
	}
	private static long nl()throws Exception{
		return Long.parseLong(next());
	}
	private static float nf()throws Exception{
		return Float.parseFloat(next());
	}
	private static double nd()throws Exception{
		return Double.parseDouble(next());
	}
	private static String ns()throws Exception{
		return br.readLine();
	}
	private static int[] nia(int n)throws Exception{
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
			arr[i] = ni();
		}
		return arr;
	}
	private static long[] nla(int n)throws Exception{
		long[] arr = new long[n];
		for(int i=0;i<n;i++){
			arr[i] = nl();
		}
		return arr;
	}
	private static long max(long a,long b){
		return Math.max(a,b);
	}
	private static double max(double a,double b){
		return Math.max(a,b);
	}
	private static long min(long a,long b){
		return Math.min(a,b);
	}
	private static double min(double a,double b){
		return Math.min(a,b);
	}
	private static long abs(long a){
		return Math.abs(a);
	}
	private static double abs(double a){
		return Math.abs(a);
	}
	//-------------------------------------------------------------------------------------------------------------//
	//-------------------------------------------------------------------------------------------------------------//
	public static void main(String[] args)throws Exception{
		new Main().timer();
	}
	private static void timer()throws Exception{
		long S = System.currentTimeMillis();
		solve();
		long E = System.currentTimeMillis();
		//pw.println("Time elapsed : "+(E-S)+" ms.");
	}
	private static void solve()throws Exception{
		int T=1;
		//int T=ni();
		for(int I=1;I<=T;I++){
			//code from here....
			long score = 0;
			int n = ni();
			long[] arr = nla(n);
			Arrays.sort(arr);
			for(int i=0;i<n-1;i++){
				score += ((i+2) * arr[i]);
			}
			score += ((long)n * arr[arr.length-1]);
			pw.println(score);
		}
	}
}