N = int(eval(input()))

A = [int(x) for x in input().split()]

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

mod = 10**9+7



partial_sum = A.copy()

sum_now = A[N-1]

for j in range(N-2,-1,-1):

    sum_now = int((sum_now+A[j])%mod)

    partial_sum[j] = sum_now

res = 0

for i in range(N-1):

    res = (res + (A[i]*partial_sum[i+1])%mod) %mod

print((int(res)))

N = int(eval(input()))

A = [int(x) for x in input().split()]

 

partial_sum = A.copy()

sum_now = A[N-1]

for j in range(N-2,-1,-1):

    sum_now = int((sum_now+A[j])%(10**9+7))

    partial_sum[j] = sum_now

res = 0

for i in range(N-1):

    res = (res + (A[i]*partial_sum[i+1])%(10**9+7)) %(10**9+7)

print((int(res)))
N = int(eval(input()))
A = [int(x) for x in input().split()]
# A = list(map(int, input().split()))
mod = 10**9 + 7
partial_sum = A.copy()
sum_now = A[N - 1]
for j in range(N - 2, -1, -1):
    sum_now = int((sum_now + A[j]) % mod)
    partial_sum[j] = sum_now
res = 0
for i in range(N - 1):
    res = (res + (A[i] * partial_sum[i + 1]) % mod) % mod
print((int(res)))

N = int(eval(input()))
A = [int(x) for x in input().split()]
partial_sum = A.copy()
sum_now = A[N - 1]
for j in range(N - 2, -1, -1):
    sum_now = int((sum_now + A[j]) % (10**9 + 7))
    partial_sum[j] = sum_now
res = 0
for i in range(N - 1):
    res = (res + (A[i] * partial_sum[i + 1]) % (10**9 + 7)) % (10**9 + 7)
print((int(res)))

-# A = list(map(int, input().split())) -mod = 10**9 + 7 -    sum_now = int((sum_now + A[j]) % mod) +    sum_now = int((sum_now + A[j]) % (10**9 + 7)) -    res = (res + (A[i] * partial_sum[i + 1]) % mod) % mod +    res = (res + (A[i] * partial_sum[i + 1]) % (10**9 + 7)) % (10**9 + 7)