# coding: utf-8

MOD = 10**9+7
N = int(input())
A = [bin(int(a))[2:] for a in input().split()]
keta = 0
for a in A:
    keta = max(keta, len(a))
A = [a.zfill(keta) for a in A]
ans = 0
for i in range(keta):
    count = [0, 0]
    for j in range(N):
        if (A[j][i] == '0'):
            count[0] += 1
        else:
            count[1] += 1
    ans += count[0] * count[1] * 2**((keta-1)-i)
    ans %= MOD
        
print(ans)