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

maxA = max(A)
K = len(str(bin(maxA)))-2
ans = 0
for k in range(K):
    N1 = 0
    N1 = sum(( (a >> k) & 1) for a in A )
    N0 = N-N1
    ans += (((1<<k)%M) *N0 *N1) % M

ans %= M    
print(int(ans))
