n = int(input())
lis = list(int(i) for i in input().split())  
sum = 0
for i in range(len(lis)):
  for j in range(len(lis)):
    if i != j:
	    sum += i ^ j
        
print(int(sum/2) % (100000000 + 7))