N=int(input())
A=list(map(int,input().split()))
M=len(bin(max(A)))-2
B=[]
MOD=10**9+7
for i in range(N):
    B.append(bin(A[i])[2:].rjust(M,'0'))
T=[0]*M
for i in range(M):
    for j in range(N):
        T[i]+=int(B[j][i])

T=T[::-1]
ans=0
for i in range(M):
    ans+=T[i]*(N-T[i])*(2**i)
    ans%=MOD
print(ans)