N = int(input())
A = sorted([int(x) for x in input().split()])
sum_s = 0
for i in range(N):
    for j in range(i, N):
        if i == j:
            continue
        sum_s += A[i] ^ A[j]
        #print("A[i]={:d}, A[j]={:d} result={:d}".format(A[i], A[j], A[i] ^ A[j]))

print(sum_s)