MOD=10**9+7

N=int(eval(input()))

A=list(map(int,input().split()))

ans=0

for j in range(60):

    k=2**j

    count=0

    for i in range(N):

        if(A[i]&k):

            ans=(ans+(2**j)*(i-count))%MOD

            count+=1

        else:

            ans=(ans+(2**j)*count)%MOD

print(ans)
MOD=10**9+7

N=int(eval(input()))

A=list(map(int,input().split()))

ans=0

for j in range(60):

    k=2**j

    count=0

    for i in range(N):

        if(A[i]&k):

            ans=(ans+k*(i-count))%MOD

            count+=1

        else:

            ans=(ans+k*count)%MOD

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

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

-            ans = (ans + (2**j) * (i - count)) % MOD +            ans = (ans + k * (i - count)) % MOD -            ans = (ans + (2**j) * count) % MOD +            ans = (ans + k * count) % MOD