import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
keta=[0]*60
for i in range(n):
    for j in range(60):
        if (a[i]>>j)&1==1:
            keta[j]+=1
print(keta)
s=sum(a)
ans=0
for i in range(n):
    s-=a[i]
    j=0
    tmp2=a[i]
    while tmp2!=0:
        if tmp2%2==1:
            keta[j]-=1
            print(j,keta[j])
            ans+=(2**j)*((n-(i+1)-keta[j]*2))
        j+=1
        tmp2=tmp2//2
    ans+=s
    ans%=mod
    # print(ans,s)
    # print(keta)
print(ans%mod)