N = int(eval(input()))

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

c=0

d=sum(A)

for i in range(0,N-1):

    d-=A[i]

    c+=A[i]*d

    if(c>10**9+7):

        c%=(10**9+7)

print(c)



N=int(eval(input()))

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

A2=0

for i in range(len(A)):

  A2+=A[i]**2

c=(sum(A))**2-A2

print((c//2%(10**9+7)))



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

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

-c = 0 -d = sum(A) -for i in range(0, N - 1): -    d -= A[i] -    c += A[i] * d -    if c > 10**9 + 7: -        c %= 10**9 + 7 -print(c) +A2 = 0 +for i in range(len(A)): +    A2 += A[i] ** 2 +c = (sum(A)) ** 2 - A2 +print((c // 2 % (10**9 + 7)))