peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
a = [int(i) for i in input().split()]

sum1 = 0
sum2 = 0

for _ in a:
  sum1 += _
  sum2 += (_*_)
sum1 = (sum1 * sum1)
print(((sum1 - sum2)//2)%1000000007)
N = int(input())
A = list(map(int, input().split()))
r = [A[0]]
m = 10**9 + 7
ans = 0

for i in range(1, N):
  r.append(A[i] + r[i - 1])
  
for i in range(N - 1):
  ans += A[i] * (r[N - 1] - r[i])

ans = ans % m

print(ans)
import numpy
n=int(input())
l=list(map(int, input().split()))
res=0
mod=10**9+7
l.append(0)
l.reverse()
cum=numpy.cumsum(l)%mod
for i in range(n):
    res+=((l[n-i]%mod)*cum[n-i-1])%mod
print(res%mod)
N = int(input())

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

S = 0
for i in range(N):
  S += A[i]

c = S
d = 0
for j in range(N):
  c -= A[j]
  c = c%(10**9+7)
  d += A[j]*c
  d = d%(10**9+7)
  
print(d)
n = int(input())
a = list(map(int, input().split()))
s = 0
c = sum(a)
for i in range(n-1):
  c -= a[i]
  s += a[i] * c
print(s % (10**9+7))
N = int( input().strip() ) ; 
arr = list ( map  ( int , input().strip().split(" ") ) ) ; 


mod = pow ( 10,  9 ) + 7 ;

arr2 = [ 0 for x in range ( N ) ] ;
for x in range ( N -1 , 0 , -1 ) :
	if x == N -1  :
		arr2[x] = arr[x] ; 
	else :
		arr2[x] = ( arr[x] + arr2[x+1] ) % mod ;
t = 0 ; 
for x in range ( N -1 ) : 
	t += ( arr[x] * arr2[x+1] ) % mod ;
	t %= mod ; 
print ( t ) ;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix_2
# CreatedDate:  2020-08-29 22:01:34 +0900
# LastModified: 2020-08-29 22:07:06 +0900
#


import os
import sys
import numpy as np
# import pandas as pd


def main():
    n = int(input())
    A = list(map(int, input().split()))
    amari = 1000000007
    ans = ((sum(A))*(sum(A)) - sum(a**2 for a in A))
    print(ans//2%amari)


if __name__ == "__main__":
    main()
N = int(input())
A = input().split()
B = [0]*N

for i in range(N):
  A[i] = int(A[i])
  B[i] = A[i]*A[i]

print( ( ( (sum(A)*sum(A)) - sum(B) ) // 2 ) % ( 10**9 + 7 ) )
import math

N = int(input())
An = [int(i) for i in input().split()]


mod = int(math.pow(10, 9) + 7)

sum_an = sum(An)
sum_result = 0

for i in range(N - 1):
    Ai = An[i]
    sum_an -= Ai
    sum_result += (Ai * sum_an) % mod


print(sum_result % mod)
N = int(input())
A = list(map(int, input().split()))
Asum = sum(A)
A2sum = 0
for i in range(N):
    A2sum += A[i]**2
print(((Asum**2-A2sum)//2)%(10**9+7))
n=int(input())
L=list(map(int,input().split()))
cnt=0
for i in range(n):
	cnt+=L[i]**2

ans=(sum(L)**2-cnt)//2
mod=pow(10,9)+7

print(ans%mod)
from itertools import accumulate
MOD = 10**9 + 7


N = int(input())
A = list(map(int, input().split()))
A_cumsum = list(accumulate(A))

ans = 0
for i in range(N-1):
    ans += A[i] * (A_cumsum[-1] - A_cumsum[i]) % MOD

print(ans % MOD)
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    su = sum(la)
    ans = 0
    mod = 10**9+7
    for a in la:
        su -= a
        ans += su*a
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    B.append(A[i]**2)
ans=(sum(A)**2-sum(B))//2
print(ans%(10**9+7))
N = int(input())
A = list(map(int, input().split()))

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

for i in num:
  s -= i
  ans += i*s
print(ans%mod)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    A_cum_sum = [A[-1]]
    for a in A[::-1][1:]:
        A_cum_sum.append(a + A_cum_sum[-1])
    A_cum_sum = A_cum_sum[::-1]
    ans = 0
    for i in range(N-1):
        sum_mod = A_cum_sum[i+1] % mod
        mul_mod = (A[i] * sum_mod) % mod
        ans = (ans + mul_mod) % mod
    print(ans)


if __name__ == '__main__':
    main()
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
s2 = sum(map(lambda x:x*x, a))
print((s**2-s2)//2 % (10**9+7))
N = int(input())
A = list(map(int, input().split()))
cum_A = [0]
mod = (10 ** 9) + 7
for i in range(N):
    cum_A.append((cum_A[i] + A[i]))

ans = 0
for i, a in enumerate(A):
    #print(f"{a}*{cum_A[N] - cum_A[i + 1]}")
    ans += a * ((cum_A[N] - cum_A[i + 1]) % mod)
    ans %= mod
    #print(ans)
print(ans)
N = int(input())
A = list(map(int,input().split()))
mod = 1000000007
sum_A = 0
for i in range(N):
    A[i] = A[i] % mod
    sum_A += A[i]

ans = 0
for i in range(N-1):
    sum_A -= A[i]
    ans = (ans + (A[i] * sum_A) % mod) % mod

print(ans)
N=int(input())
MOD=10**9+7
A=[int(x) for x in input().split()]
sumA=sum(A)
ans=0
for i in range(N):
    now=A[i]
    sumA-=now
    ans+=now*sumA
    ans%=MOD

print(ans)
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()
total=sum(a)

mod=10**9+7

ans=0
for i in range(n-1):
  total-=a[i]
  ans+=a[i]*total
  ans%=mod

print(ans)
n,a,m,s,r = int(input()),list(map(int,input().split())),(10**9)+7,0,0
for i in range(n): s = (s+a[i])%m
for i in range(n):
    s = (s-a[i])%m
    r = (r+(a[i]*s))%m
print(r%m)
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
f = sum(a)
ans = 0
for i in range(n):
  f = f-a[i]
  ans+= ((f*a[i])%mod)
  ans%=mod
print(ans)
import sys
 
stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))
 
 
def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    s = sum(A)
    q = sum([a ** 2 for a in A])
    ans = (((s * s) - q)) // 2
    print(int(ans % mod))
 
 
if __name__ == '__main__':
    main()
n=int(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(input())
A=list(map(int,input().split()))

limit=10**9+7
S=[0]
for i in range(N):
    A[i]=A[i]%limit
for i in range(1,N):
    S.append((S[i-1]+A[-i])%limit)
ans=0
for i in range(N-1):
    ans+=A[i]*S[-1-i]
    ans=ans%limit
print(ans)
INF=10**9+7
n=int(input())
A=list(map(int,input().split()))
S=[sum(A)]
ans=0
for i in range(len(A)):
    key=S[-1]
    S.append(key-A[i])
    ans+=(A[i]*S[-1])
    
print(ans%INF)
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10 ** 9 + 7


def main():
    ans = 0
    cs = np.cumsum(np.array(a))
    for i in range(n-1):
        s = (cs[-1] - cs[i]) % mod
        ans = (ans+(a[i]*int(s)) % mod) % mod
    return ans


n, *a = map(int, read().split())
a = main()
print(a)
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
const = 1000000007
ans = 0

n = i_in()
a = l_in(int)

ins = 0
for i in range(1, n):
    ins += a[i-1]
    ans += ins * a[i]

print(ans%const)
n=int(input())
l=list(map(int,input().split()))
infin=10**9+7
s=0
for i in range(0,len(l)):
  s+=l[i]
ans=0
for i in range(len(l)-1,0,-1):
  s=s-l[i]
  ans=(ans+l[i]*s)%infin
print(ans)
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    mod = 10**9+7
    # a_sum = sum(A)
    a_cum = [0] * (n+1)
    for i in range(n):
        a_cum[i + 1] = a_cum[i] + A[i]
    ans = 0
    for i in range(len(A)-1):
        ans += A[i] * (a_cum[n] - a_cum[i+1])
    ans %= mod
    print(ans)

if __name__ == '__main__':
    main()
# Python template 
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()


n = int(input())
a = get_array()

pre_sum = [0]

for i in range(n-1,-1,-1):
    pre_sum.append(pre_sum[-1]+a[i])

pre_sum = pre_sum[::-1]
mod = 1000000007
ans = 0
for i in range(n):
    ans = (ans+a[i]*pre_sum[i+1])%mod 

print(ans)
mod = 10**9+7
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in a:
    ans += i
ans = ans**2
for i in a:
    ans -= i**2
print((ans//2)%mod)
N = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

B = [0] * (N + 1)
for i in range(N):
    B[i + 1] = (B[i] + A[i]) % MOD

ans = 0
tmp = B[-1]
for i in range(N):
    ans += (A[i] * (tmp - B[i + 1])) % MOD
    ans %= MOD

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

S=S[::-1]
i=0
ans=0
while i<N:
    ans+=A[i]*S[i+1]
    ans%=M
    i+=1
print(ans)
MOD=10**9+7
N=int(input())
A=list(map(int,input().split()))
ans=sum(A)**2
ans-=sum(map(lambda x: x**2, A))
ans//=2
print(ans%MOD)
N = int(input())
A = list(map(int, input().split()))

X = 0
Ans = 0

for i in range(N - 1):
    X += A[i]
    Ans += X * A[i + 1]
    Ans = Ans % (10 ** 9 + 7)

print(Ans)
import itertools
n=int(input())
a=list(map(int,input().split()))
b=list(itertools.accumulate(a))
ans=0
for i in range(n-1):
  ans+=a[-i-1]*b[-i-2]
  ans%=10**9+7
print(ans)
N=int(input())
A=list(map(int,input().split()))
#437235829 mod(10^9+7)
sumAcol=0
sumA=0
sumtr=0
for i in range(N):
  sumtr+=A[i]**2
  sumAcol+=A[i]
  sumtr=sumtr % (10**9+7)
  sumAcol=sumAcol % (10**9+7)

for i in range(N):
  sumA+=(sumAcol*A[i])%(10**9+7)
  
sumA=(sumA-sumtr)+10**9+7

print(sumA*(5*10**8+4) % (10**9+7))
N=int(input())
A=list(map(int, input().split()))
B=[A[0]]
for i in range(1,N):
    B.append(B[i-1]+A[i])
p=10**9+7
ans=0
for i in range(1,N):
    ans+=A[i]*B[i-1]
ans%=p
print(ans)
p = 10**9+7
s = 0
s_sq = 0

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

for i in range(N):
    s += A[i]
    s_sq += A[i]**2
    s %= p
    s_sq %= p

print((s**2 - s_sq) * pow(2, p-2, p) % p)
N = int(input())
A = list(map(int, input().split()))


def mod10_9_7(num):
    return num % (10**9+7)


seki = A[-1]

ans = 0
for i in range(N-2, -1, -1):
    ans += A[i] * seki
    seki += A[i]
print(mod10_9_7(ans))
def mod(num):
    return num % (10 ** 9 + 7)


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

Asum = sum(A)

ans = 0

for i, a in enumerate(A):
    Asum -= a
    ans = mod(ans + Asum * a)

print(ans)
n=int(input())
a=list(map(int,input().split()))
su=sum(a)
ru=[0 for i in range(n)]
ru[0]=su-a[0]

for i in range(1,n):
    ru[i]=ru[i-1]-a[i]
ans=0
for i in range(0,n-1):
    ans+=(a[i]*(ru[i]%1000000007))%1000000007
    ans=ans%1000000007
print(ans)
N = int(input())
A = list(map(int,input().split()))
ans = 0
suma = sum(A)
for i in range(N-1):
    suma -= A[i]%(10**9+7)
    ans += (A[i] * suma )%(10**9+7)
print(ans%(10**9+7))
n = int(input())
lst = list(map(int, input().split()))
	
suffS = []
lst = lst[::-1]
summ = 0
for i in lst:
	suffS.append(summ)
	summ += i
res = 0
for i in range(n):
	res += suffS[i] * lst[i]
	res %= (10**9+7)
print(res)
#abcdef
#a*b,a*c,a*d,a*e,a*f
#b*c,b*d,b*e,b*f
#c*d,c*e,c*f
#d*e,d*f
#e*f

n = int(input())
l = list(map(int,input().split()))

mod = 10**9 + 7
all_l = 0
for i in range(n):
    all_l += l[i]
    all_l %= mod

ans = 0
for i in range(n-1):
    all_l = (all_l-l[i])%mod
    ans += (l[i]*all_l)%mod
    ans %= mod

print(ans)
#C - Sum of product of pairs
N = int(input())
A = list(map(int,input().split()))
SUM = 0
jsum= 0
MOD = 1000000007
for j in range(N):
    jsum = (jsum + A[j]) % MOD

for i in range(N-1):
    jsum = (jsum - A[i]) % MOD
    SUM = ( SUM + (jsum * A[i] % MOD ) ) % MOD

# 出力
print(SUM)
n = int(input())
a = list(map(int, input().split()))
subsum = a[n-1]
ans = 0
for b in reversed(a[:n-1]):
  ans = ans + b * subsum
  subsum = subsum + b
print(ans % (10**9 + 7))
n= int(input())
mod=10**9+7
a= [int(x ) for x in input().split()]
b= a[:]

s=0
for i in range(n-2,-1,-1):
    b[i]=b[i+1]+b[i]
for i in range(n):
    s += (b[i]-a[i])*a[i]
print(s%mod)
n = int(input())
a = list(map(int,input().split()))
count = 0
su = sum(a)
for i in range(n-1):
	su -= a[i]
	count += a[i]*su
print(count%(10**9+7))
N = int(input())
A = list(map(int, input().split()))

sum_A = 0
S = []

for i in range(1,N):
    sum_A += A[-1*i]
    S.append(sum_A)

ans = 0

for i in range(N-1):
    tmp = A[N-2-i] * S[i]
    ans += tmp

ans = ans % (10 ** 9 + 7)
print(ans)
MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))

ans = sum(a)**2
for i in range(n):
    ans -= a[i]*a[i]
ans //= 2
ans %= MOD
print(ans)
def findProductSum(A, n): 
      
    array_sum = sum(A)
    array_sum_square = array_sum ** 2
    
    individual_square_sum = 0
    for i in range(n): 
        individual_square_sum += A[i] * A[i] 
  
    return (array_sum_square - individual_square_sum) // 2

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

print(findProductSum(A, N)%(10**9+7))
n = int(input())
a = list(map(int, input().split()))

nums = [0]*n
nums[0] = a[0]
for i in range(1,n): nums[i] = a[i]+nums[i-1]

ans = 0
for i in range(n-1):
  ans += a[i]*(nums[n-1]-nums[i])
  ans %= 10**9+7
print(ans)
n = int(input())
a = list(map(int, input().split()))
k = 0
num = sum(a)
t = 10 ** 9 + 7

for i in a:
    num -= i
    k += num * i

ans = k % t
print(ans)
N = int(input())
A = list(map(int, input().split()))
#print(A)

total = 0
left = 0
sum = sum(A)
#print(end)

for i in range(N - 1):
    #print(i, A[i])
    left = left + A[i]
    #start = i + 1
    #for j in range(start, N):
        #print(i, j)
        #sum = sum + A[j]
    #print(A[i], sum)
    right = sum - left
    #print(i, left, right, A[i])
    total = (total + A[i] * right) % 1000000007

print(total)
def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    SUM = [sum(A)]
    for i in range(1,N):
        SUM.append((SUM[i-1]-A[i-1])%(10**9+7))
    
    ans = 0
    for i in range(N-1):
        ans += A[i]*SUM[i+1]
        ans = ans%(10**9+7)
    
    print(ans)
    
if __name__ == '__main__':
    main()
N = int(input())
A = input().split()

toA = 0
for i in range(N):
    A[i] = int(A[i])
    toA += A[i]

ans = 0
for i in range(0, N):
    toA -= A[i]
    ans += A[i]*toA

print(ans % 1000000007)
def c_sum_of_product_of_pairs(MOD=10**9 + 7):
    N = int(input())
    A = [int(i) for i in input().split()]

    total = sum(A)
    cumsum = [0]
    for i in range(N):
        cumsum.append(cumsum[-1] + A[i])

    return sum([(total - cumsum[i]) * A[i - 1] for i in range(1, N)]) % MOD

print(c_sum_of_product_of_pairs())
n = int(input())
s = list(map(int, input().split()))

ans= 0
total = sum(s)

for i in range(len(s)-1):
  total -= s[i]
  ans += total * s[i]

print(ans % (10**9 +7))
n = int(input())
a = list(map(int, input().split()))
ans = 0
r_wa = [a[0]]
for i in range(n) :
  if i>0 :
    r_wa.append(r_wa[i-1]+a[i])

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

A=sum(a)%mod
total=0

for i in range(n-1):
    A-=a[i]
    total+=A*a[i]
    total%=mod

print(total)
n = int(input())
a_list = list(map(int, input().split()))

s_2 = 0
for i in a_list:
    s_2 += i**2

ans = (sum(a_list)**2 - s_2)//2  

ans = ans%(10**9+7)
print(ans)
N = int(input())
A = list(map(int, input().split()))

M = 10 ** 9 + 7
T = sum(map(lambda x: x**2, A))
print (((sum(A)**2-T)//2)%M)
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)
N = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7
tot = sum(A)
ans = 0

for i in range(N):
    tot -= A[i]
    lin = tot * A[i]
    ans += lin % mod
    ans %= mod

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

ans = 0
s = sum(A)
for i in range(N-1):
    s -= A[i]
    ans += A[i]*s
    
print(ans%((10**9)+7))
N = int(input())
a = list(map(int,input().split()))
ans = 0
total = 0
for i in range(N):
    if i != 0:
        total += a[i-1]
        ans += a[i]*total
print(ans%(10**9 + 7))
N = int(input())
x = list(map(int, input().split()))
s = sum(x) - x[0]
ans = 0

for i in range(N-1):
  ans = ans + x[i]*s
  s = s - x[i+1]
ans = ans % 1000000007
  
  
print(ans)
N = int(input())
A = list(map(int,input().split()))

mod = 10**9 + 7
ans = 0
A_sum = [0]

for i in range(N):
    A_sum.append(A_sum[-1] + A[i])

for i in range(N-1):
    ans += A[i] * (A_sum[N] - A_sum[i+1])
    ans %= mod

print(ans)
N = int(input())
A_list = list(map(int, input().split()))
#myans_list =  [ [0 for n in range(N)] for nn in range(N) ]
#myans = 0
#for n in range(N):
#    for nn in range(N):
#        myans_list[n][nn] = A_list[n] * A_list[nn]
#for n in myans_list:
#    print(n)
mysum = sum(A_list)
myans = 0
for n in range(N-1):
    mysum -= A_list[n]
    myans +=  mysum*A_list[n]
print(myans%(1000000007))
N = int(input())

A = list(map(lambda x: int(x), input().split(' ')))

res = ((sum(A)**2 - sum(list(map(lambda x: x**2, A)))) // 2) % (10**9 + 7)

print(int(res))
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
S = sum(A) % mod
for i in range(n):
  S =(S- A[i]) % mod
  ans += S * A[i]
  ans %= mod
print(ans)
n = int(input())
a = list(map(int, input().split()))

ans = 0

for i in range(2,n+1):
  a[-i] += a[-i+1]

for i in range(len(a)-1):
  ans = ans % 1000000007 + ((a[i] - a[i+1]) * a[i+1]) % 1000000007
    
print(ans % 1000000007)
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
N = int(input())
A = list(map(int,input().split()))
a0 = ((sum(A)%p)*(sum(A)%p))%p
a1 = 0
for i in range(N):
    a1 = (a1+A[i]**2)%p
a = a0-a1
a = (pow(2,p-2)*a)%p
print(a)
N=int(input())
L=list(map(int,input().split()))
ans=0
a=sum(L)
mod=1000000007
for i in range(N):
  ans+=L[i]*(a-L[i])
  ans%=mod
if ans%2==0:
  print(ans//2)
else:
  print((ans+mod)//2)
n = int(input())
A = list(map(int, input().split()))


mod = 10**9+7
s = sum(A)

ans = 0

for i in range(n):
    s -= A[i]
    ans += (A[i] * s) % mod

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

ans = 0
total = sum(A)
for i in range(N - 1):
    total -= A[i]
    ans += (A[i] * total) 

print(ans % mod)
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
cnt=sum(a)
ans=0
for i in range(n):
    ans+=a[i]*(cnt-a[i])
    ans%=mod
    cnt-=a[i]
print(ans)
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
ans = 0
for i in range(n - 1):
    s -= a[i]
    ans += a[i] * s
print(ans % (10 ** 9 + 7))
ans = 0
N = int(input())
array = list(map(int, input().split()))
x = sum(array)
y = 0
for i in range(N):
  y += array[i]**2

ans = x**2 -y
print((ans//2)%(10**9+7))
N = int(input())
A = list(map(int, input().split()))
T = sum(A)
ans = 0
for i in range(N):
  T -= A[i]
  ans += A[i] * T
  ans %= 10 ** 9 + 7
print(ans)
n=int(input())
s=list(map(int ,input().split()))

sum=[0]*n

sum[-1]=s[-1]

for i in range(n-2,-1,-1):
    sum[i]=sum[i+1]+s[i]

ans=0
for i in range(n-1):
    ans=ans+sum[i+1]*s[i]

print(ans%(1000000007))
N = int(input())
A = list(map(int, input().split()))

s = 0
for i in range(N):
    s += A[i]

ans = 0
for i in range(N-1):
    s -= A[i]
    p = A[i] * s
    p %= (10 ** 9 + 7)
    ans += p
print(ans%(10 ** 9 + 7))
import numpy as np


def main():
    n = int(input())
    As = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    As_sum = sum(As)
    ans = 0

    for i in range(n):
        As_sum -= As[i]
        ans += As_sum * As[i]
        ans %= mod
    ans %= mod
    print(ans)



if __name__ == "__main__":
    main()
n = int(input())
a = list(map(int, input().split()))
p = 1000000007
 
z = 0
for i in range(n):
    z += a[i]
    z = z % (2 * p)
 
y = (z ** 2) % (2 * p)
 
x = 0
for j in range(n):
    x += a[j] ** 2
    x = x % (2 * p)
 
w = int(((y - x) / 2) % p)
print(w)
mod=10**9+7
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N)]
B[0]=sum(A)-A[0]
count=(A[0]*B[0])%mod
for i in range(1,N):
    B[i]=B[i-1]-A[i]
    count=(count+A[i]*B[i])%mod
print(count)
def main():
    N = int(input())
    A = list(map(int,input().split()))
    ans = 0
    m0 = 10**9+7
    Ar = [0]*N
    sum0 = 0
    for i in reversed(range(N)):
        sum0 = (sum0 + A[i]) % m0
        Ar[i] = sum0

    for i in range(N-1):
        ans = (ans + A[i] * Ar[i+1]) % m0
    print(ans)

if __name__ == '__main__':
    main()
N = int(input())
A = [int(i) for i in input().split()]

mod = 10 ** 9 + 7

sum = [0] * N
A = A[::-1]
sum[0] = A[0]
for i in range(1, N) :
  sum[i] = (sum[i - 1] + A[i]) % mod
  
sum = sum[::-1]
A = A[::-1]

ret = 0
for i in range(N - 1) :
  ret += A[i] * sum[i + 1] % mod
  ret %= mod
  
print(ret)
n = int(input())
al = list(map(int, input().split()))
mod = 10**9+7
ans = sum(al)**2

for ai in al:
    ans -= ai**2

print((ans//2)%mod)
N = int(input())
A = list(map(int,input().split()))

S = sum(A)
S2 = sum(map(lambda x: x*x,A))
ans = ((S*S - S2)//2)%1000000007
print(int(ans))
def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    sum_list = [0 for _ in range(n)]
    sum_list[0] = sum(a_list)
    ans = 0

    for i in range(1, n):
        sum_list[i] = sum_list[i - 1] - a_list[i - 1]

    for i in range(n - 1):
        ans += a_list[i] * sum_list[i + 1] % (10 ** 9 + 7)

    print(ans % (10 ** 9 + 7))


if __name__ == "__main__":
    main()
N = int(input())
A = list(map(int, input().split()))

answer = 0
x = 0
for i in range(len(A) - 1):
  x += A[i]
  answer +=  (x * A[i + 1])

print(answer% (10**9 + 7))
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

cums = [0]
for a in A:
    cums.append(cums[-1] + a)

ans = 0
for i,a in enumerate(A):
    ans += a*(cums[-1] - cums[i+1])
    ans %= MOD
print(ans)
N = int(input())
A = list(map(int, input().split()))
wa = 0
a = 0
for l in range(N-1):
    a += A[N-l-1]
    wa += a * A[N-l-2]
print(wa % (10**9+7))
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    mod = 10**9 + 7
    sum_A = sum(A)%mod
    ans = 0
    for a in A:
        sum_A -= a
        ans += a*sum_A%mod
    print(ans%mod)

if __name__=='__main__':
    main()
N = int(input())
A = list(map(int,input().split()))
B = sum(A)
new_A = A.reverse()
n = 0
for i in range(N-1):
    n += A[i]*(B-A[i])
    B = B-A[i]

print(n%(10**9+7))
n=int(input())
a=list(map(int,input().split()))

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

s = sum(a)
ans = 0
for i in range(n):
    s -= a[i]
    ans += s*a[i]
    ans %= mod
    
print(ans%mod)
n = int(input())
a = [int(s) for s in input().split()]
b = []
val = 0
sum_val= 0
for i in range(0, n):
    b.append(a[i] * sum_val) 
    sum_val+= a[i] 
val = sum(b)
print(val % (10 ** 9 + 7))
n = int(input())
a = list(map(int, input().split()))
b = sum(a)
ans = 0

for i in range(0, n):
    b = b - a[i]
    ans = ans + a[i] * b
    ans = ans % 1000000007

print(ans)
import numba
from numba import njit, b1, i4, i8, f8
import numpy as np  # noqa

N = int(input())
A = [int(x) for x in input().split()]


def main(A):
    ans = 0
    s = 0
    for i in range(N - 2, -1, -1):
        s += A[i + 1]
        s %= 10**9 + 7
        ans = (ans + A[i] * s) % (10**9 + 7)
    return ans


print(main(A))
n=int(input())
a=list(map(int,input().split()))

ans=0
x=0
for i in range(n):
  ans += a[i] * x
  x +=a[i]
print(ans%(10**9+7))