import numpy as np
n = int(input())
L = np.array([int(i) for i in input().split()], dtype="uint64")
out = 0
modu = pow(10,9)+7

for i in range(n-1):
  T = (L ^ np.roll(L,i+1) ) % modu
  out += int((np.sum(T) % modu))
  out = out % modu
print(out//2)