N = int(input())
A = [int(i) for i in input().split()]
MOD = 10e9 + 7
bit = []
for ith_dig in range(len(bin(max(A))) - 2):
    num_0 = 0
    num_1 = 0
    for i in range(N):
        if str(A[i]).zfill(len(bin(max(A))) - 2)[ith_dig] == 0:
            num_0 += 1
        else:
            num_1 += 1
    bit.append(num_0 * num_1)
bit.reverse()
ans = 0
for i in range(len(bit)):
    ans += bit[i] * pow(2, i)
print(ans)
