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 = a//2, a%2
    key = int(sum(b))
    ans += p*(n-key)*key
    ans = ans%inf
    p *= 2
    p %= inf
print(ans)