import sys
input = sys.stdin.readline
N = int(input())
A = tuple(map(int,input().split()))
b = 0
num = 1000000007
A_1 = A[:-1]
A_2 = A[1:]
for i in A_1:
    for j in A_2:
        b += i ^ j
    A_2 = A_2[1:]
    #print(A_2)
print(b%num)
