import sys

n=int(input())
alst=list(map(int,sys.stdin.readline().strip().split()))

cumsum=[[0]*(n+1) for i in range(60)]

md=10**9+7

for i in range(1,n+1):
    a=alst[i-1]
    dig=0
    while dig<60:
        bit=a%2
        cumsum[dig][i]=cumsum[dig][i-1]+bit
        dig+=1
        a//=2

ans=0
ceff=1

for d in range(60):
    ret=0
    for i in range(1,n):
        ret+=(cumsum[d][i]-cumsum[d][i-1])*(n-i-cumsum[d][n]+cumsum[d][i])
        ret+=(1-cumsum[d][i]+cumsum[d][i-1])*(cumsum[d][n]-cumsum[d][i])
    ans=(ans+ceff*ret)%md
    ceff=(2*ceff)%md

print(ans)

