from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

X = [[0] * N for i in range(61)]
for i, a in enumerate(A):
    for j in range(61):
        if (1 << j) & a:
            X[j][i] = 1

for i in range(61):
    X[i] = list(accumulate((X[i])))


ans = 0
for i, a in enumerate(A):
    for j in range(61):
        x = X[j][-1] - X[j][i]
        if (1 << j) & a:
            ans += (1 << j) * ((N - i - 1) - x)
            ans %= MOD

        else:
            ans += (1 << j) * x
            ans %= MOD


print(ans % MOD)
