input()
a = list(map(int, input().split()))
a.sort(reverse=True)
x = 0
y = 1
for i in a:
    x += y * i
    y <<= 1
print(x)