n = int(input()) alst = list(map(int, input().split())) ans = 0 alst.sort(reverse = True) for i, a in enumerate(alst, 1): ans += (i.bit_length() - 1) * a print(ans)