n = int(input()) a = sorted([int(i) for i in input().split()] , reverse = True) ans = 0 for i in range(len(a)) : ans = ans + pow(2,i)*a[i] print(ans)