from itertools import accumulate

n = int(eval(input()))

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

MOD = 10**9+7



Acum = list(accumulate(A))

ans = 0

for i, a in enumerate(reversed(A[1:])):

    ans += Acum[n-i-2]*a

    ans %= MOD





print(ans)

n = int(eval(input()))

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

S = sum(A)

T = sum([x**2 for x in A])

print(((S**2-T)//2 % (10**9+7)))

from itertools import accumulate

n = int(eval(input()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
Acum = list(accumulate(A))
ans = 0
for i, a in enumerate(reversed(A[1:])):
    ans += Acum[n - i - 2] * a
    ans %= MOD
print(ans)

n = int(eval(input()))
A = list(map(int, input().split()))
S = sum(A)
T = sum([x**2 for x in A])
print(((S**2 - T) // 2 % (10**9 + 7)))

-from itertools import accumulate - -MOD = 10**9 + 7 -Acum = list(accumulate(A)) -ans = 0 -for i, a in enumerate(reversed(A[1:])): -    ans += Acum[n - i - 2] * a -    ans %= MOD -print(ans) +S = sum(A) +T = sum([x**2 for x in A]) +print(((S**2 - T) // 2 % (10**9 + 7)))