M = 10**9 + 7

N = int(eval(input()))

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



table = [0] * (N)

for i in range(N-1):

    table[i+1] = table[i] + A[N-i-1]

table = table[::-1]



ans = 0

for i in range(N-1):

    ans = (ans + table[i]*A[i]) % M



print(ans)

M = 10**9 + 7

N = int(eval(input()))

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



print(((((sum(A)**2) - sum([x*x for x in A])) // 2) % M))

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

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

-table = [0] * (N) -for i in range(N - 1): -    table[i + 1] = table[i] + A[N - i - 1] -table = table[::-1] -ans = 0 -for i in range(N - 1): -    ans = (ans + table[i] * A[i]) % M -print(ans) +print(((((sum(A) ** 2) - sum([x * x for x in A])) // 2) % M))