N = int(input())
A = [int(i) for i in input().split()]
A.sort()
list_A = []
num_A = []
list_A.append(A[0])
j = 1
cnt = 1
while(j<=N-1):
    if A[j-1]==A[j]:
        cnt += 1
        if j == N-1:
            num_A.append(cnt)
    else:
        list_A.append(A[j])
        num_A.append(cnt)
        cnt = 1
        if j == N-1:
            num_A.append(cnt)
    j += 1
len_A = len(list_A)
j = 0
k = 1
xor = 0
while(j<=len_A-2):
    xor += (list_A[j]^list_A[k])*(num_A[j]*num_A[k])
    k += 1
    if k == len_A:
        j += 1
        k = j+1
print(xor%(10**9+7))