N = int(input())
A = [int(i) for i in input().split()]

sum = 0
for i in range(len(A)-1):
  for j in range(i+1, len(A)):
    sum += A[i] ^ A[j]
    #print(i, j, sum)

ans = sum % (10**9 + 7)
print(ans)