import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
inf = 10**9+7

ans = 0
p = 1
for i in range(61):
    a, b = divmod(a, 2)
    key = np.sum(b)
    ans += p*(n-key)*key
    ans = ans%inf
    p *= 2
print(ans)