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) { Scanner in = new Scanner(System.in); int n = in.nextInt(); Integer[] calories = new Integer[n]; for(int calories_i=0; calories_i < n; calories_i++){ calories[calories_i] = in.nextInt(); } long sum = 0; long j = 1; Arrays.sort(calories, new IntegerComparator()); for (int i = 0; i < n; i++) { sum += j * calories[i]; j = j * 2; } System.out.println(sum); } private static class IntegerComparator implements Comparator { @Override public int compare(Integer o1, Integer o2) { return o2.compareTo(o1); } } }