N = int(eval(input()))

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

Asum = sum(A) % (10**9 + 7)

ans = 0



for i in range(N):

  ans += A[i] * (Asum-A[i]) % (10**9 + 7)

  Asum -= A[i]



print((ans % (10**9 + 7)))
N = int(eval(input()))

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

mod = 10**9 + 7

s = 0

for i in a:

  s += i

ans = 0

for i in range(N):

  s -= a[i]

  ans += a[i] * s % mod

print((ans%mod))

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

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

-A = list(map(int, input().split())) -Asum = sum(A) % (10**9 + 7) +a = list(map(int, input().split())) +mod = 10**9 + 7 +s = 0 +for i in a: +    s += i -    ans += A[i] * (Asum - A[i]) % (10**9 + 7) -    Asum -= A[i] -print((ans % (10**9 + 7))) +    s -= a[i] +    ans += a[i] * s % mod +print((ans % mod))