N = int(eval(input()))

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



mod = 10**9 + 7

ans = 0



for d in range(60):

    n0, n1 = 0, 0

    for i in range(N):

        if (A[i] >> d) & 1:

            n1 += 1

        else:

            n0 += 1

    ans = (ans + (n0 * n1) * (1 << d))% mod

    

print(ans)
import numpy as np



N = int(eval(input()))

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



mod = 10**9 + 7

ans = 0



for i in range(60):

    c = len(A[A&1==1])

    A >>= 1

    ans = (ans + c*(N-c)*pow(2,i,mod))%mod



print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for d in range(60):
    n0, n1 = 0, 0
    for i in range(N):
        if (A[i] >> d) & 1:
            n1 += 1
        else:
            n0 += 1
    ans = (ans + (n0 * n1) * (1 << d)) % mod
print(ans)

import numpy as np

N = int(eval(input()))
A = np.array(list(map(int, input().split())))
mod = 10**9 + 7
ans = 0
for i in range(60):
    c = len(A[A & 1 == 1])
    A >>= 1
    ans = (ans + c * (N - c) * pow(2, i, mod)) % mod
print(ans)

+import numpy as np + -A = list(map(int, input().split())) +A = np.array(list(map(int, input().split()))) -for d in range(60): -    n0, n1 = 0, 0 -    for i in range(N): -        if (A[i] >> d) & 1: -            n1 += 1 -        else: -            n0 += 1 -    ans = (ans + (n0 * n1) * (1 << d)) % mod +for i in range(60): +    c = len(A[A & 1 == 1]) +    A >>= 1 +    ans = (ans + c * (N - c) * pow(2, i, mod)) % mod