n = int(eval(input()))

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

mod = 10**9+7



ans = 0



sum_j = [0] * n

sum_tmp = 0



for i in reversed(list(range(n))):

    sum_tmp += a[i]

    sum_j[i] = sum_tmp



for i in range(n-1):

    ans += a[i] * sum_j[i+1] % mod



print((ans % mod))

n = int(eval(input()))

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



S = sum(A)

S2 = sum([x * x for x in A])



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

n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
sum_j = [0] * n
sum_tmp = 0
for i in reversed(list(range(n))):
    sum_tmp += a[i]
    sum_j[i] = sum_tmp
for i in range(n - 1):
    ans += a[i] * sum_j[i + 1] % mod
print((ans % mod))

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

-a = list(map(int, input().split())) -mod = 10**9 + 7 -ans = 0 -sum_j = [0] * n -sum_tmp = 0 -for i in reversed(list(range(n))): -    sum_tmp += a[i] -    sum_j[i] = sum_tmp -for i in range(n - 1): -    ans += a[i] * sum_j[i + 1] % mod -print((ans % mod)) +A = list(map(int, input().split())) +S = sum(A) +S2 = sum([x * x for x in A]) +print(((S * S - S2) // 2 % (10**9 + 7)))