n = int(input())
aaa = list(map(int, input().split()))

MOD = 10 ** 9 + 7
ans = 0
m = 1
ans = 0
for _ in range(60):
    one_count = 0
    for a in aaa:
        one_count += (a & m) // m
    zero_count = n - one_count
    ans += (one_count * zero_count * m)
    m *= 2
        
print(ans)
