N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N - 1):
    ni = A[i]
    # print(ni)
    for j in range(i + 1, N):
        nj = A[j]

        # print("\t"+str(nj))
        # print(bin(ni ^ nj))
        ans += int(bin(ni ^ nj)[2:], 2)
print(ans)