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