N=int(input())
MOD=10**9+7
L=60
ls=[int(s) for s in input().split()]
bils=[]
for i in range(N):
  val_ls=[0 for j in range(L)]
  for j in range(L):
    if (2**j)&ls[i]>0:
      val_ls[j]=1
  bils.append(val_ls)
bisumls=[[0 for _ in range(L)] for _ in range(N)]
bisumls[N-1]=bils[N-1]
for i in range(2,N):
  for j in range(L):
    bisumls[-i][j]=bisumls[-i+1][j]+bils[-i][j]
#[[0, 0, 0], [3, 0, 2], [2, 0, 2], [2, 0, 1], [1, 0, 1]]
ans=0
ans_ls=[0 for _ in range(L)]
for i in range(N-1):
  #print(bils[i],bisumls[i+1])
  for k in range(L):
    if bils[i][k]==1:
      a=N-i-1-bisumls[i+1][k]
    else:
      a=bisumls[i+1][k]
   #   print(a)
    ans_ls[k]+=a
ans=0
base=1
for k in range(L):
  ans+=base*ans_ls[k]%MOD
  base=base*2%MOD
print(ans%MOD)
  