from itertools import accumulate





N, *A = list(map(int, open(0).read().split()))

MOD = 1_000_000_007



acc = list(accumulate(A, initial=0))

ans = 0

for i in range(1, N):

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

    ans %= MOD

print(ans)

from itertools import accumulate





N = int(eval(input()))

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

MOD = 1_000_000_007

acc = list(accumulate(A, initial=0))



ans = 0

for i in range(N):

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

    ans %= MOD

print(ans)

from itertools import accumulate

N, *A = list(map(int, open(0).read().split()))
MOD = 1_000_000_007
acc = list(accumulate(A, initial=0))
ans = 0
for i in range(1, N):
    ans += A[i - 1] * (acc[N] - acc[i])
    ans %= MOD
print(ans)

from itertools import accumulate

N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 1_000_000_007
acc = list(accumulate(A, initial=0))
ans = 0
for i in range(N):
    ans += A[i] * (acc[N] - acc[i + 1])
    ans %= MOD
print(ans)

-N, *A = list(map(int, open(0).read().split())) +N = int(eval(input())) +A = list(map(int, input().split())) -for i in range(1, N): -    ans += A[i - 1] * (acc[N] - acc[i]) +for i in range(N): +    ans += A[i] * (acc[N] - acc[i + 1])