N = int(eval(input()))

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

cum = [0] * (N-1)

now = 0

for i in range(N-1):

    now += A[-(i+1)]

    cum[i] = now

ans = 0

for i in range(N-1):

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

    ans %= (10**9+7)

print((ans % (10**9+7)))
N = int(eval(input()))

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

SUMA = sum(A)

MOD = 10**9 + 7

C = [0] * (N-1)

for i in range(N-1):

  SUMA -= A[i]

  C[i] = SUMA

ans = 0

for i in range(N-1):

  ans += A[i]*C[i]

  ans %= MOD

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

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

-cum = [0] * (N - 1) -now = 0 +SUMA = sum(A) +MOD = 10**9 + 7 +C = [0] * (N - 1) -    now += A[-(i + 1)] -    cum[i] = now +    SUMA -= A[i] +    C[i] = SUMA -    ans += A[i] * cum[-(i + 1)] -    ans %= 10**9 + 7 -print((ans % (10**9 + 7))) +    ans += A[i] * C[i] +    ans %= MOD +print(ans)