N = int(eval(input()))

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

sumA = sum(A)

c = 0



for i in range(N-1):

    c+= A[i]* (sumA-A[i])

    sumA-= A[i]

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

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

sumA = sum(A)

c = 0

for a in A:

  c += a**2

print((((sumA**2 - c)//2) % (10**9+7)))
N = int(eval(input()))
A = list(map(int, input().split()))
sumA = sum(A)
c = 0
for i in range(N - 1):
    c += A[i] * (sumA - A[i])
    sumA -= A[i]
print((c % (10**9 + 7)))

N = int(eval(input()))
A = list(map(int, input().split()))
sumA = sum(A)
c = 0
for a in A:
    c += a**2
print((((sumA**2 - c) // 2) % (10**9 + 7)))

-for i in range(N - 1): -    c += A[i] * (sumA - A[i]) -    sumA -= A[i] -print((c % (10**9 + 7))) +for a in A: +    c += a**2 +print((((sumA**2 - c) // 2) % (10**9 + 7)))