import sys
F = 10**9+7
n = int(input())
s = sys.stdin.readline().split()
s_ = [int(i) for i in s]
ss = [bin(i) for i in s_]
ans = 0
for i in range(n-1):
  for j in range(n-1-i):
    ans+=(int(s[i])^int(s[i+j+1]))
    
print(ans%F)
  