n = int(eval(input()))

A = [*list(map(int, input().split()))]

S = [0] * (n+1)

for i in range(n): S[i+1] = S[i] + A[i]

MOD = (10**9)+7

ans = 0

for i in range(n): ans = (ans + A[i] * (S[-1] - S[i+1])) % MOD

print(((ans + MOD) % MOD))

n = int(eval(input()))

A = [*list(map(int, input().split()))]

MOD = (10**9)+7

sum_a = sum(A)

ans = 0

for i in range(n-1):

    sum_a -= A[i]

    ans = (ans + A[i] * sum_a) % MOD

print(((ans + MOD) % MOD))

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

n = int(eval(input()))
A = [*list(map(int, input().split()))]
MOD = (10**9) + 7
sum_a = sum(A)
ans = 0
for i in range(n - 1):
    sum_a -= A[i]
    ans = (ans + A[i] * sum_a) % MOD
print(((ans + MOD) % MOD))

-S = [0] * (n + 1) -for i in range(n): -    S[i + 1] = S[i] + A[i] +sum_a = sum(A) -for i in range(n): -    ans = (ans + A[i] * (S[-1] - S[i + 1])) % MOD +for i in range(n - 1): +    sum_a -= A[i] +    ans = (ans + A[i] * sum_a) % MOD