n = int(input().strip()) c = list(map(int, input().strip().split(' '))) a = 0 c.sort(reverse=True) for i in range(n): a += c[i]*(2**i) print (a)