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