M = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))

zero = [0] * 60
one = [1] * 60
pow2 = [2 ** i % M for i in range(60)]


def bitcnt(a):
    j = 0
    bits = [0] * 60
    while a:
        bits[j] = a & 1
        a >>= 1
        j += 1
    return bits


ans = 0
a1 = bitcnt(A[0])
a0 = [(x + 1) % 2 for x in a1]
for i in range(1, N):
    bits1 = bitcnt(A[i])
    bits0 = [(x + 1) % 2 for x in bits1]
    ans += sum(pow2[i] * (a0[i] * bits1[i] % M) % M for i in range(60))
    ans %= M
    ans += sum(pow2[i] * (a1[i] * bits0[i] % M) % M for i in range(60))
    ans %= M
    a1 = [(a1[i] + bits1[i]) % M for i in range(60)]
    a0 = [(a0[i] + bits0[i]) % M for i in range(60)]

print(ans)
