n = int(eval(input()))

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

s = sum(a)

ans = 0

mod = pow(10, 9) + 7

for i in a:

    s -= i

    ans = (ans + s * i) % mod

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

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

mod = pow(10, 9) + 7

s = sum(a) % mod

ans = s * s % mod

for i in a:

    ans -= i * i

    ans %= mod

ans = ans * pow(2, mod - 2, mod) % mod

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
s = sum(a)
ans = 0
mod = pow(10, 9) + 7
for i in a:
    s -= i
    ans = (ans + s * i) % mod
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
mod = pow(10, 9) + 7
s = sum(a) % mod
ans = s * s % mod
for i in a:
    ans -= i * i
    ans %= mod
ans = ans * pow(2, mod - 2, mod) % mod
print(ans)

-s = sum(a) -ans = 0 +s = sum(a) % mod +ans = s * s % mod -    s -= i -    ans = (ans + s * i) % mod +    ans -= i * i +    ans %= mod +ans = ans * pow(2, mod - 2, mod) % mod