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(map(int, input().split()))



mod = 10 ** 9 + 7



res = 0

for d in range(60):

    one = sum(x & 1 for x in arr)

    res += one * (n - one) * (1 << d)

    res %= mod

    arr = [x >> 1 for x in arr]



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(map(int, input().split()))
mod = 10**9 + 7
res = 0
for d in range(60):
    one = sum(x & 1 for x in arr)
    res += one * (n - one) * (1 << d)
    res %= mod
    arr = [x >> 1 for x in arr]
print(res)

-    one = sum(x % 2 == 1 for x in arr) -    res += one * (n - one) * 2**d +    one = sum(x & 1 for x in arr) +    res += one * (n - one) * (1 << d) -    arr = [x // 2 for x in arr] +    arr = [x >> 1 for x in arr]