import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
A = sorted(list(map(int, inputs[1].split())))
MOD = 10 ** 9 + 7

ans = 0
for i in range(n-1):
    for j in range(i, n):
        ans += A[i] ^ A[j]
        ans %= MOD
print(ans)