import numpy as np
n=int(input())
a=np.array(list(map(lambda x:list(map(int,list(('0'*62+bin(int(x))[2:])[-62:]))),input().split())),np.int64)
mod=pow(10,9)+7
b=np.sum(a,axis=0)
ans=0
for i in range(61):# 2^iの位
  ans+=(pow(2,i,mod)*b[-i-1]*(n-b[-i-1]))%mod
  ans%=mod
print(ans)