n=int(input())
a=list(map(int,input().split()))
MOD=10**9+7
m=max(a)
s=bin(m)
l=len(s[2:])
h=[0]*l
su=0
for i in range(n):
    s=bin(a[i])
    su+=a[i]%MOD
    for j in range(len(s)-2):
        if s[len(s)-j-1]=='1':
            h[j]+=1
count=0
for i in range(n):
    count+=su
    su-=a[i]%MOD
    s=bin(a[i])
    for j in range(len(s)-2):
        if s[len(s)-j-1]=='1':
            k=pow(2,j,MOD)
            x=(k*(n-h[j]*2-i))%MOD
            count+=x
            count%=MOD
            h[j]-=1
    #print(count,h)
print(count)