import numpy as np
N = int(input())
A = np.array(list(map(int, input().split(' '))))
mod = 10 ** 9 + 7
ans = 0
for n, i in enumerate(A[:-1]):
    ans += sum((A[n:] ^ i)) % mod
    ans %= mod
print(ans)
