import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))
ans = 0

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

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

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