mod = 10**9 + 7



N = int(eval(input()))

A = [int(x) for x in input().split()]

S = sum(A) % mod



ans = 0

for i in range(N):

    S -= A[i]

    if S < 0: S += mod



    ans += S * A[i]

    ans %= mod

print(ans)
mod = 10**9 + 7

N = int(eval(input()))

A = [int(x) for x in input().split()]



s = sum(A)

S = s**2

D = sum([a**2 for a in A])



print((int((S - D) // 2) % mod))

mod = 10**9 + 7
N = int(eval(input()))
A = [int(x) for x in input().split()]
S = sum(A) % mod
ans = 0
for i in range(N):
    S -= A[i]
    if S < 0:
        S += mod
    ans += S * A[i]
    ans %= mod
print(ans)

mod = 10**9 + 7
N = int(eval(input()))
A = [int(x) for x in input().split()]
s = sum(A)
S = s**2
D = sum([a**2 for a in A])
print((int((S - D) // 2) % mod))

-S = sum(A) % mod -ans = 0 -for i in range(N): -    S -= A[i] -    if S < 0: -        S += mod -    ans += S * A[i] -    ans %= mod -print(ans) +s = sum(A) +S = s**2 +D = sum([a**2 for a in A]) +print((int((S - D) // 2) % mod))