N = int(eval(input()))

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

t = 0 

S = sum(A)

c = 0 

for i in range(len(A) - 1): 

        S -= A[i]

        t = (t + (A[i] * S)) % 1000000007

print(t)
N = int(eval(input()))

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

t = 0 

S = sum(A)

c = 0 

for i in range(len(A) - 1): 

        S -= A[i]

        t = (t + (A[i] * S))

print((t % 1000000007))
N = int(eval(input()))
A = list(map(int, input().split()))
t = 0
S = sum(A)
c = 0
for i in range(len(A) - 1):
    S -= A[i]
    t = (t + (A[i] * S)) % 1000000007
print(t)

N = int(eval(input()))
A = list(map(int, input().split()))
t = 0
S = sum(A)
c = 0
for i in range(len(A) - 1):
    S -= A[i]
    t = t + (A[i] * S)
print((t % 1000000007))

-    t = (t + (A[i] * S)) % 1000000007 -print(t) +    t = t + (A[i] * S) +print((t % 1000000007))