n = int(input())
li_a = list(map(int, input().split()))
li_b = []
for x in reversed(li_a):
  li_b.append(x)
a = 0
mod = 10**9 + 7
for i in range(n-1):
  b = li_b.pop()
  for x in li_b:
    a += b^x
print(a%mod)