N=int(input())
A=[int(x) for x in input().split()]
A.sort()

mod = 10**9 + 7
ans = 0
k=1
while A[-1]>0:
    t = 0
    for i in range(N):
        t+=A[i]%2
        A[i]//=2
    ans = (ans + (N-t)*t*(2**(k-1))%mod)%mod
    k +=1
print(ans)
