N = int(eval(input()))

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

MOD = 10**9 + 7

S = sum(A) % MOD



ans = 0

for a in A:

    S -= a

    ans += S * a

    ans %= MOD

print(ans)

N = int(eval(input()))

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

MOD = 10**9 + 7



S = 0

ans = 0

for a in A:

    ans = (ans + a * S) % MOD

    S += a

print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
S = sum(A) % MOD
ans = 0
for a in A:
    S -= a
    ans += S * a
    ans %= MOD
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
S = 0
ans = 0
for a in A:
    ans = (ans + a * S) % MOD
    S += a
print(ans)

-S = sum(A) % MOD +S = 0 -    S -= a -    ans += S * a -    ans %= MOD +    ans = (ans + a * S) % MOD +    S += a