import java.util.*; public class Solution { public static void main(String[] args) { 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(); } in.close(); Arrays.sort(calories); System.out.println(getCalorieCount(calories)); } private static long getCalorieCount(int[] calories) { long res = 0L; for (int j = 0; j < calories.length; j++) res += Math.pow(2, j) * -calories[j]; return res; } }