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

print(ans)
