from collections import defaultdict

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

max_A = max(A)
j = 0
while max_A >> j > 0:
    j += 1
max_j = j

c = defaultdict(int)
ans = 0
MOD = 10 ** 9 + 7
for i in range(N - 2, -1, -1):
    Ai = A[i + 1]
    for j in range(max_j):
        c[(j, Ai >> j & 1)] += 1
    Ai = A[i]
    for j in range(max_j):
        ans += (1 << j) * c[(j, (Ai >> j & 1 ^ 1))]
    ans %= MOD
print(ans)
