N = int(input())
a = list(map(int,input().split()))

ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans += a[i] ^ a[j]
    #print(ans)
print(ans % (10**9 + 7))

# for i in range(N-1):
#     ans += sum(a[i+1:]) ^ a[i] + (N - a[i])
#     print(sum(a[i+1:]) ^ a[i])
#     #for j in range(i+1,N):
#     #    ans += a[i] ^ a[j]
# print(ans % (10**9 + 7))