N=int(eval(input()))

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

#437235829 mod(10^9+7)

sumAcol=0

sumA=0

sumtr=0

for i in range(N):

  sumtr+=A[i]**2

  sumAcol+=A[i]

  sumtr=sumtr % (10**9+7)

  sumAcol=sumAcol % (10**9+7)



for i in range(N):

  sumA+=(sumAcol*A[i])%(10**9+7)

  

sumA=(sumA-sumtr)+10**9+7



print((sumA*(5*10**8+4) % (10**9+7)))



N=int(eval(input()))

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

sumA=sum(A)

result=0

for i in range(N):

  sumA-=A[i]

  result+=A[i]*sumA

  result=result % (10**9+7)

  

print(result)
N = int(eval(input()))
A = list(map(int, input().split()))
# 437235829 mod(10^9+7)
sumAcol = 0
sumA = 0
sumtr = 0
for i in range(N):
    sumtr += A[i] ** 2
    sumAcol += A[i]
    sumtr = sumtr % (10**9 + 7)
    sumAcol = sumAcol % (10**9 + 7)
for i in range(N):
    sumA += (sumAcol * A[i]) % (10**9 + 7)
sumA = (sumA - sumtr) + 10**9 + 7
print((sumA * (5 * 10**8 + 4) % (10**9 + 7)))

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

-# 437235829 mod(10^9+7) -sumAcol = 0 -sumA = 0 -sumtr = 0 +sumA = sum(A) +result = 0 -    sumtr += A[i] ** 2 -    sumAcol += A[i] -    sumtr = sumtr % (10**9 + 7) -    sumAcol = sumAcol % (10**9 + 7) -for i in range(N): -    sumA += (sumAcol * A[i]) % (10**9 + 7) -sumA = (sumA - sumtr) + 10**9 + 7 -print((sumA * (5 * 10**8 + 4) % (10**9 + 7))) +    sumA -= A[i] +    result += A[i] * sumA +    result = result % (10**9 + 7) +print(result)