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