N = int(input())
A = list(map(int,input().split()))
cnt = [0 for i in range(60)]

for i in A:
    tmp = format(i, '060b')
    for j in range(60):
        if tmp[j] == "1":
            cnt[j] += 1

ans = 0
for i in range(60):
    ans += (2 ** (59-i)) * cnt[i] * (N -cnt[i])

print(ans)