N = int(eval(input()))

A = tuple(map(int, input().split(' ')))

MOD = 10 ** 9 + 7



zeros = [0] * 60

ones = [0] * 60



for a in A:

    for i, bit in enumerate(reversed(format(a, '060b'))):

        if bit == '0':

            zeros[i] += 1

        else:

            ones[i] += 1



base = 1

ans = 0



for i in range(len(zeros)):

    ans += zeros[i] * ones[i] * base

    ans %= MOD

    base *= 2

    base %= MOD



print(ans)

import numpy as np



N = int(eval(input()))

A = tuple(map(int, input().split(' ')))

A = np.array(A, dtype=np.int64)

MOD = 10 ** 9 + 7



ans = 0

mask = 1



for i in range(60):

    ones = np.count_nonzero(A & mask)

    ans += (ones * (N - ones) % MOD) * (mask % MOD)

    ans %= MOD

    mask <<= 1



print(ans)

N = int(eval(input()))
A = tuple(map(int, input().split(" ")))
MOD = 10**9 + 7
zeros = [0] * 60
ones = [0] * 60
for a in A:
    for i, bit in enumerate(reversed(format(a, "060b"))):
        if bit == "0":
            zeros[i] += 1
        else:
            ones[i] += 1
base = 1
ans = 0
for i in range(len(zeros)):
    ans += zeros[i] * ones[i] * base
    ans %= MOD
    base *= 2
    base %= MOD
print(ans)

import numpy as np

N = int(eval(input()))
A = tuple(map(int, input().split(" ")))
A = np.array(A, dtype=np.int64)
MOD = 10**9 + 7
ans = 0
mask = 1
for i in range(60):
    ones = np.count_nonzero(A & mask)
    ans += (ones * (N - ones) % MOD) * (mask % MOD)
    ans %= MOD
    mask <<= 1
print(ans)

+import numpy as np + +A = np.array(A, dtype=np.int64) -zeros = [0] * 60 -ones = [0] * 60 -for a in A: -    for i, bit in enumerate(reversed(format(a, "060b"))): -        if bit == "0": -            zeros[i] += 1 -        else: -            ones[i] += 1 -base = 1 -for i in range(len(zeros)): -    ans += zeros[i] * ones[i] * base +mask = 1 +for i in range(60): +    ones = np.count_nonzero(A & mask) +    ans += (ones * (N - ones) % MOD) * (mask % MOD) -    base *= 2 -    base %= MOD +    mask <<= 1