N=int(input())
A=[int(x) for x in input().split()]
S=[[0]*60 for x in range(N+1)]

for i,a in enumerate(A):
  c=0
  while a>0:
    if a&1!=0:
      S[i+1][c]=1
    a>>=1
    c+=1
  for c in range(60):
    S[i+1][c]+=S[i][c]

s=0
for i,a in enumerate(A[:N-1]):
  c,i=0,i+1
  while c<60:
    s+=2**c*((S[N][c]-S[i][c]) if a&1==0 else (N-S[N][c]+S[i][c]-i))
    s%=10**9+7
    a>>=1
    c+=1

print(s)
