n = input() cs = list(reversed(sorted(map(int, raw_input().split())))) for i in range(len(cs)): cs[i] = 2**i * cs[i] print sum(cs)