import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner readIn = new Scanner(System.in); int n = readIn.nextInt(); int[] arr = new int[n]; for(int ii = 0; ii < n; ii++) arr[ii] = readIn.nextInt(); Arrays.sort(arr); long output = 0; long multiplier = 1; for(int ii = n - 1; ii >= 0; ii--) { output += arr[ii] * multiplier; multiplier <<= 1; } System.out.println(output); } }