MOD=10**9+7
N=int(input())
A=list(map(int,input().split()))
bit=[[0]*60 for i in range(N+1)]
for i in range(1,N+1):
    for j in range(60):
        if(A[i-1]>>j&1):
            bit[i][j]=bit[i-1][j]+1
        else:
            bit[i][j]=bit[i-1][j]
res=0
for i in range(N):
    for j in range(60):
        if not (A[i]>>j&1):
            res=(res+(2**j)*bit[i][j])%MOD
        else:
            res=(res+(2**j)*(i-bit[i][j]))%MOD
print(res)