n=int(eval(input()))

mod=10**9+7

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



a=sum(A)

a=(a**2)



b=0

for i in range(n):

  b+=(A[i])**2

if a-b<0:

  c=a-b

  while c<=0:

    c+=mod

  

  ans=c//2

  ans=ans%mod



else:

  ans=(a-b)//2

  ans=ans%mod



print(ans)
n=int(eval(input()))

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

mod=10**9+7

INf=float('inf')



Acc=[0]*(n+1)

for i in range(1,n+1):

  Acc[i]=(Acc[i-1]+A[i-1])%mod



ans=0  

for i in range(n):

  s=A[i]*(Acc[n]-Acc[i+1])

  ans+=s%mod



print((ans%mod))
n = int(eval(input()))
mod = 10**9 + 7
A = list(map(int, input().split()))
a = sum(A)
a = a**2
b = 0
for i in range(n):
    b += (A[i]) ** 2
if a - b < 0:
    c = a - b
    while c <= 0:
        c += mod
    ans = c // 2
    ans = ans % mod
else:
    ans = (a - b) // 2
    ans = ans % mod
print(ans)

n = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
INf = float("inf")
Acc = [0] * (n + 1)
for i in range(1, n + 1):
    Acc[i] = (Acc[i - 1] + A[i - 1]) % mod
ans = 0
for i in range(n):
    s = A[i] * (Acc[n] - Acc[i + 1])
    ans += s % mod
print((ans % mod))

+A = list(map(int, input().split())) -A = list(map(int, input().split())) -a = sum(A) -a = a**2 -b = 0 +INf = float("inf") +Acc = [0] * (n + 1) +for i in range(1, n + 1): +    Acc[i] = (Acc[i - 1] + A[i - 1]) % mod +ans = 0 -    b += (A[i]) ** 2 -if a - b < 0: -    c = a - b -    while c <= 0: -        c += mod -    ans = c // 2 -    ans = ans % mod -else: -    ans = (a - b) // 2 -    ans = ans % mod -print(ans) +    s = A[i] * (Acc[n] - Acc[i + 1]) +    ans += s % mod +print((ans % mod))