n = int(eval(input()))

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



mod = 10**9+7



cs = [0]

for a in A:

    cs.append(cs[-1]+a)

cs = cs[1:]



ans = 0

for i in range(n):

    ans += A[i] * (cs[-1]-cs[i])

    ans %= mod

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

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



mod = 10**9+7



x = (((sum(A))**2) // 2)

x -= (sum([a**2 for a in A]) // 2)

x %= mod

print(x)
n = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
cs = [0]
for a in A:
    cs.append(cs[-1] + a)
cs = cs[1:]
ans = 0
for i in range(n):
    ans += A[i] * (cs[-1] - cs[i])
    ans %= mod
print(ans)

n = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
x = ((sum(A)) ** 2) // 2
x -= sum([a**2 for a in A]) // 2
x %= mod
print(x)

-cs = [0] -for a in A: -    cs.append(cs[-1] + a) -cs = cs[1:] -ans = 0 -for i in range(n): -    ans += A[i] * (cs[-1] - cs[i]) -    ans %= mod -print(ans) +x = ((sum(A)) ** 2) // 2 +x -= sum([a**2 for a in A]) // 2 +x %= mod +print(x)