import numpy as np
N = int(input())
A = np.fromstring(input(), dtype=np.int64, sep=' ')
print(A)
res = 0
for bit in range(60):
    c = int((A & 1).sum())
    res += c * (N - c) * (1 << bit)
    A >>= 1

print(res % 1000000007)