n=int(input())
A=[int(i) for i in input().split()]
B=[0]*60
C=[0]*60
ans=0
mod=10**9+7
for i,a in enumerate(A):
  for j in range(60):
    if a%2==0:
      C[j]+=B[j]
    else:
      C[j]+=i-B[j]
      B[j]+=1
    a//=2
for i in range(60):
  ans=(ans+C[i]*(2**i))%mod
print(ans)
