import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))
mod = 10 ** 9 + 7

ans = 0
for i in range(64):
    tmp = A & 1
    A >>= 1
    x = tmp.sum()
    x *= n - x
    ans += pow(2, i, mod) * x % mod

print(ans % mod)
