n = input() cakes = map(int,raw_input().split()) cakes = sorted(cakes,reverse=True) mins = 0 for j in range(n): mins += (2**j)*cakes[j] print mins