n = int(input()) a = sorted(map(int, input().split()), reverse=True) i = 0 ans = 0 for k in range(100): for _ in range(2 ** k): if i == n: print(ans) exit() ans += k * a[i] i += 1