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
for i in range(n):
    buf=a[i]
    for j in range(l):
        h[j]+=buf%2
        buf//=2
#print(h)
count=0
su=sum(a)
for i in range(n):
    count+=su
    su-=a[i]
    s=bin(a[i])
    #print(s)
    for j in range(len(s)-2):
        if s[len(s)-j-1]=='1':
            k=pow(2,j,MOD)
            count+=k*(n-h[j]*2-i)
            count%=MOD
            h[j]-=1
    #print(count,h)
print(count)