#!/bin/python3 #121:7 import sys n = int(input().strip()) calories = list(map(int, input().strip().split(' '))) # your code goes here c = sorted(calories, key = int, reverse = True) sum=0 for i in range(len(c)): sum+=c[i]*(2**i) #print(c[i]) print(sum)