N = int(input()) A = sorted(map(int, input().split()), reverse=True) ans = 0 for i, a in enumerate(A, 1): ans += a * (i.bit_length() - 1) print(ans)