N = int(input())
A = list(map(int, input().split()))
A.sort()
sum = 0
cnt = []
for i in range(N-1):
    if A[i] in cnt:
        sum += a
    else:
        for j in range(i+1, N):
            a = A[i] ^ A[j]
            sum += a
print(sum%1000000007)