n=int(input())
l=list(map(int,input().split()))
ans=0
MOD=10**9+7
la=[0 for i in range(61)]
for i in range(61):
    la[60-i]=sum([j//2**(60-i) for j in l])
    l=[j%2**(60-i) for j in l]
for num,i in enumerate(la):
    ans+=2**num*i*(n-i)
    ans%=MOD
print(ans)