#yuki1416 n=int(input()) a=sorted(list(map(int,input().split())),reverse=True) res=0 for i,x in enumerate(a,1): res+=x*(i.bit_length()-1) print(res)