n = int(input())
nums =["INF"] + list(map(int,input().split()))

counter = 0

sigma1 = [x for x in range(1,n)]

for s1 in sigma1:
  counter  += sum([nums[s1]^nums[x] for x in range(s1 + 1,n+1)])
  
  #for s2 in sigma2:
  #  counter += nums[s1] ^ nums[s2]



print(counter % (10 ** 9 + 7))
  