import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { int sum=0,i=0,a=0; Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] calories = new int[n]; for(int calories_i=0; calories_i < n; calories_i++){ calories[calories_i] = in.nextInt();} for(a=calories.length;a>0;a--) { Arrays.sort(calories); // a=calories.length; sum=(int)(sum+((a)*(Math.pow(2,i)))); i++; } System.out.println(sum);// your code goes here }}