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

sum = 0

for i in range(N):
  for j in range(i,N):
    if (i!=j):
      sum += A[i] ^ A[j]
      #print(A[i] ^ A[j])

ans = sum % (1000000007)
#出力
#print(N)
#print(A)
#print(' ')
#print(sum)
print(ans)