N = int(input())
A = input().split(" ")
A = list(map(int,A))
sum = 0

for i in range(len(A)):
    for j in range(len(A)-i -1 ):
        sum += A[i] ^ A[j + i + 1]

#sum = sum * 2

#for i in range(len(A)):
#    sum += A[i] ^ A [i] 

print(int(sum%(10 ** 9 +7)))