N = int(eval(input()))

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

D = [[0, 0] for _ in range(60)]



for a in A:

    for i in range(60):

        if (a >> i) & 1:

            D[i][1] += 1

        else:

            D[i][0] += 1



ans = 0

mod = 10 ** 9 + 7



for idx, d in enumerate(D):

    ans = (ans + (d[0] * d[1] * (1 << idx))) % mod



print(ans)
N = int(eval(input()))

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

ones = [0] * 60



for a in A:

    i = 0

    while (1 << i) <= a:

        ones[i] += ((a >> i) & 1)

        i += 1



ans = 0

mod = 10 ** 9 + 7



for idx, one in enumerate(ones):

    ans = (ans + one * (N - one) * (1 << idx)) % mod



print(ans)

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

N = int(eval(input()))
A = list(map(int, input().split()))
ones = [0] * 60
for a in A:
    i = 0
    while (1 << i) <= a:
        ones[i] += (a >> i) & 1
        i += 1
ans = 0
mod = 10**9 + 7
for idx, one in enumerate(ones):
    ans = (ans + one * (N - one) * (1 << idx)) % mod
print(ans)

-D = [[0, 0] for _ in range(60)] +ones = [0] * 60 -    for i in range(60): -        if (a >> i) & 1: -            D[i][1] += 1 -        else: -            D[i][0] += 1 +    i = 0 +    while (1 << i) <= a: +        ones[i] += (a >> i) & 1 +        i += 1 -for idx, d in enumerate(D): -    ans = (ans + (d[0] * d[1] * (1 << idx))) % mod +for idx, one in enumerate(ones): +    ans = (ans + one * (N - one) * (1 << idx)) % mod