import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

ans = 0
for i in range(N - 1):
    xj = np.array([A[i] for i in range(i + 1, N)])
    ans += sum(A[i] ^ xj)

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