n = input() a = [int(x) for x in input().split()] a.sort() a.reverse() s = 0 j = 0 for c in a: s += 2**j * c j += 1 print(s)