n=int(input())
table=[0]*60
for i,v  in enumerate(map(int,input().split())):
    for j in range(60):
        table[j]+=v%2
        v//=2
        if v==0:break
#print(*table,sep='\n')
ans=0
mod1,mod2=10**9+7,998244353
mod=mod1
a=1
for o in table:
    z=n-o
    ans=(ans+o*z*a)%mod
    a=a*2%mod
print(ans)