n = int(eval(input()))

arr = list([format(int(n), '060b')[::-1] for n in input().split()])



mod = 10 ** 9 + 7



res = 0

power_of_two = 1

for d in range(60):

    one = sum(x[d] == "1" for x in arr)

    res += one * (n - one) * power_of_two

    res %= mod

    power_of_two *= 2

    power_of_two %= mod



print(res)

n = int(eval(input()))

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



mod = 10 ** 9 + 7



res = 0

for d in range(60):

    one = sum(x % 2 == 1 for x in arr)

    res += one * (n - one) * 2 ** d

    res %= mod

    arr = [x // 2 for x in arr]



print(res)

n = int(eval(input()))
arr = list([format(int(n), "060b")[::-1] for n in input().split()])
mod = 10**9 + 7
res = 0
power_of_two = 1
for d in range(60):
    one = sum(x[d] == "1" for x in arr)
    res += one * (n - one) * power_of_two
    res %= mod
    power_of_two *= 2
    power_of_two %= mod
print(res)

n = int(eval(input()))
arr = list(map(int, input().split()))
mod = 10**9 + 7
res = 0
for d in range(60):
    one = sum(x % 2 == 1 for x in arr)
    res += one * (n - one) * 2**d
    res %= mod
    arr = [x // 2 for x in arr]
print(res)

-arr = list([format(int(n), "060b")[::-1] for n in input().split()]) +arr = list(map(int, input().split())) -power_of_two = 1 -    one = sum(x[d] == "1" for x in arr) -    res += one * (n - one) * power_of_two +    one = sum(x % 2 == 1 for x in arr) +    res += one * (n - one) * 2**d -    power_of_two *= 2 -    power_of_two %= mod +    arr = [x // 2 for x in arr]