mod=1000000007
ans=0
n=int(input())
a=[int(i) for i in input().split()]
x=[[0]*63 for i in range(n)]
for i in range(n):
    d=bin(a[i])[2:]
    for j,k in enumerate(d[::-1]):
        x[i][j]=x[i-1][j]+[0,1][k=='1']
#print(x)
for i in range(n-1):
    #print(a[i])
    d=bin(a[i])[2:]+'0'*65
    #print(d)
    for j in range(63):
        r=x[-1][j]-x[i][j]
        if d[j]=='1':
            ans+=(2**j)*r
        else:
            ans+=(2**j)*(n-i-r)
        #r=(n-i)-(x[-1][j]-x[i][j])
        #ans+=(2**j)*r
        ans%=mod
print(ans)
