N = int(eval(input()))

MOD = 1000000007

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

cum = [0]*(N+1)

for i in range(N):

    cum[i+1] = cum[i] + A[i]

    cum[i+1] %= MOD



ans = 0



for i in range(N-1):

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

    ans %= MOD



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

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

S = 0

S2 = 0

MOD = 1000000007

for i in range(N):

  S += A[i]

  S2 += A[i]*A[i]

print(((S*S-S2)//2%MOD))
N = int(eval(input()))
MOD = 1000000007
A = list(map(int, input().split()))
cum = [0] * (N + 1)
for i in range(N):
    cum[i + 1] = cum[i] + A[i]
    cum[i + 1] %= MOD
ans = 0
for i in range(N - 1):
    ans += A[i] * (cum[N] - cum[i + 1])
    ans %= MOD
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
S = 0
S2 = 0
MOD = 1000000007
for i in range(N):
    S += A[i]
    S2 += A[i] * A[i]
print(((S * S - S2) // 2 % MOD))

+A = list(map(int, input().split())) +S = 0 +S2 = 0 -A = list(map(int, input().split())) -cum = [0] * (N + 1) -    cum[i + 1] = cum[i] + A[i] -    cum[i + 1] %= MOD -ans = 0 -for i in range(N - 1): -    ans += A[i] * (cum[N] - cum[i + 1]) -    ans %= MOD -print(ans) +    S += A[i] +    S2 += A[i] * A[i] +print(((S * S - S2) // 2 % MOD))