import numpy as np
n = int(input())
N = 60

a = map(int, input().split())
nums = []
for aa in a:
    b = list(reversed(list(map(int, format(aa, "060b")))))
    nums.append(b)
nums = np.array(nums)
res = 0
MOD = int(1e9+7)

for i, col in enumerate(nums.T):
    k = n*(n-1)/2
    n1 = col.sum()
    n0 = n-col.sum()
    k -= n1*(n1-1)/2
    k -= n0*(n0-1)/2
    res += (1 << i) * k
    res %= MOD

print(int(res))
