n = int(raw_input())
arr = map(int,raw_input().split())
arr = sorted(arr, reverse = True)
res = 0
for i in range(n):
    res += arr[i]*(2**i)
print res

5e8fe920913bd811624e498ba232dc30b717d24f
n = int(raw_input())
arr = map(int,raw_input().split())
arr = sorted(arr, reverse = True)
res = 0
for i in range(n):
    res += arr[i]*(2**i)
print res
