peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
a = list(map(int, input().split()))

b = []
for i in range(n):
  for j in range(i+1, n):
    b.append((a[i] * a[j]) % (10 ** 9 + 7))
print(sum(b))
def pro(A, n):
    prr = 0
    for i in range(n):
        for j in range(i + 1, n):
            prr = prr + A[i] * A[j]
    return prr


if __name__ == "__main__":
    u=0
    u=int(input())
    A = list(map(int,input().split()))
    n = len(A)



    print(pro(A, n))
N=int(input())
A=list(map(int,input().split()))
#Ai*Ajの和を求めろ
s=sum(A)
ans=0
for i in A:
    s=s-i
    ans+=i*s
print(ans)
import itertools
import numpy as np
N = int(input())
A = list(map(int, input().split()))

p = itertools.combinations(A, 2)
emp = []
for v in p:
    a = np.prod(v)
    emp.append(a)
print(sum(emp))
N = int(input())
a = list(map(int, input().split(" ")))
s = 0
for i in range(0,N):
  s += a[i]

s = s*s

for i in range(0,N):
  s -= a[i]*a[i]

if s % 2 == 0:
  s = s/2 % (10**9 +7)
else:
  s = (s + 10**9 + 7)/2 % (10**9 + 7)
 
print(int(s))
import sys
from collections import defaultdict

input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

D = defaultdict(int)
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        v = A[i] * A[j] % MOD
        D[v] += 1
print(D)
n = int(input())
a = list(map(int, input().split()))
k = 0
num = sum(a)
import math

for i in range(n):
    reje = num - a[i]
    k += reje * a[i]

x = int(k/2)
t = 10 ** 9 + 7
ans = x % t
print(ans)
N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)%(1000000007)
sumA2 = (sumA * sumA)%(1000000007)
square = 0
for i in range(N):
    square +=  ( A[i]**2 ) % (1000000007)
    square = square % (1000000007)
buf = sumA2 - square
if buf < 0:
  buf = buf + (1000000007)
res = ( buf * ((1000000007+1)/2)) % 1000000007
print(round(res))
import numpy as np
N = int(input())
# = str(input())
# = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

total = (sum(A)%(10**9+7))**2
doubleA = (np.asarray(A)%(10**9+7))**2

minustotal = sum(doubleA)

print(((total-minustotal)//2)%(10**9+7))
n = int(input())
lst = list(map(int, input().split()))

MOD = 1000000007

def mod(n):         
  return n % MOD

def multiply(a, b): #mod(a*b)を求める
  return mod(mod(a)*mod(b))

ans = mod(multiply(mod(sum(lst)), mod(sum(lst))))

for i in range(n):
  ans -= multiply(lst[i], lst[i])
  
ans = mod(ans)
print(ans//2)
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += (A[i] * A[j]) % (10 ** 9 + 7)
print(ans)
import numpy as np
N = input()
A = list(map(int,input().split()))
s = 0
for i in range(len(A)):
  for j in range(i+1,len(A)):
    s = s + A[i]*A[j]
    
print(s)
n = int(input())
a = list(map(int, input().split(" ")))
mod = 10 ** 9 + 7
s=0
for i in range(n):
    s += a[i]
    s %= mod
s = s*s
s %= mod
for i in range(n):
    s -= (a[i] ** 2) % mod
    s %= mod
s /= 2
s %= mod
print(int(s))
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

ans = 0
sa = sum(a)%mod

for i in a:
    ans += (sa*i)%mod-i*i%mod
    ans %= mod
print(ans//2)
N=int(input())
A =list(map(int,input().split()))
sum =0
for i in range(N):
    for j in range(i+1,N):
        sum += A[i]*A[j]
x =sum
a =10**9+7
result =''

while x>0:
    result = str(x % a) + result
    x//=a
    print(result)
import sys
import numpy as np

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))

a = np.array(a, dtype=np.uint64)
s = ((
    (np.sum(a)**2).astype(np.uint64) - np.sum(a**2)
) // 2).astype(np.uint64)

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

S = sum(A)
ans = 0

for i in range(N):
  ans += A[i]*(S-A[i])
  
ans = ans % (10**9+7)

print(ans//2)
def findProductSum(A, n): 
    array_sum = 0
    individual_square_sum = 0
    for i in range(0, n): 
        array_sum = array_sum + A[i] 
        individual_square_sum += A[i] * A[i] 
  
    array_sum_square = array_sum * array_sum 
    return (array_sum_square - individual_square_sum) / 2
  
if __name__ == '__main__': 
    n = int(input())
    A = list(map(int, input().split()))
    print(int(findProductSum(A, n)%1000000007))
u=0
u=int(input())
A = list(map(int,input().split()))
n = len(A)
prr = 0
for i in range(n):
    for j in range(i + 1, n):
        prr = prr + A[i] * A[j]
print(prr)
n = int(input())
a = list(map(int,input().split()))

a2=[a[n-1]]
for i in range(n-1,0,-1):
    a2.append(a2[-1]+a[i-1])
print(a2)
ans=0
for i in range(n-1):
    ans = ( ans + (a[i]*a2[-i-2]) )%(10**9+7)
print(ans)
import math
n=int(input())	
s=0	
su=0	
t=0
k=0
a=list(map(int,input().split()))
if n==1:
	print(a[0])
else:
	for i in range(n):
		s+=a[i]
		k=math.pow(s,2)
		su+=math.pow(a[i],2)
		t=(k-su)//2
	print(round(t))
N=int(input())
A=list(map(int,input().split()))
def selfmult(x):
    return (x%1000000007)**2
dot=((sum(A)%1000000007)**2-sum(map(selfmult,A)))/2
print(int(dot)%1000000007)
mod=(10**9)+7
n=int(input())
a=list(map(int,input().strip().split(' ')))
s=0
for x in a:
	s= (s+x)%mod
s=(s*s)%mod
t=0
for x in a:
	t= (t+ (x*x)%mod)%mod
ans=((((s-t)%mod+mod)%mod)//2)
print(ans%mod)
N = int(input())
A = [int(x) for x in input().split()]

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

for i in range(0,N):
    x=A[i]**2
    D+=x

for j in range(0,N):
    S+=A[j]
    F=S**2

T=(F-D)/2
T=int(T)

ans=T%L
print(ans)
n=int(input())

A=list(map(int,input().split()))
sum=0
for j in range(n):
  for i in range(j):
    seki=A[i]*A[j]
    keta=seki%(10**10)
    sum+=keta
    sum=sum%(10**10)
    
print(sum % (10**9+7))
n = int(input())
s = list(map(int,input().split()))

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

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

t = 0
for i in range(N):
  t += (A[i]**2 % (10**9+7))
t %= (10**9+7)

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

N = int(input())
A = [int(num)%mod for num in input().split()]

A_sum = sum(A)
A_squared = sum([num**2 for num in A])

ans = (A_sum**2 - A_squared)/2
ans = int(ans%mod)
print(ans)
N = int(input())
A = [int(x) for x in input().split()]
partial_sum = A.copy()
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = int((sum_now+A[j])%(1e9+7))
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1]) %(1e9+7)) %(1e9+7)
print(int(res))
CONST = 10**9 + 7
n = int(input())
a = list(map(int,input().split()))
s = pow(sum(a),2,CONST)
for x in a:
    s -= pow(x,2)
    s %= CONST
    if s < 0: s += CONST
print(s//2)
mod = (10**9)+7
def findProductSum(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = (array_sum + A[i])%mod
    array_sum_square = (array_sum * array_sum)%mod
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum = (individual_square_sum + A[i] * A[i])%mod
    tmp = (((array_sum_square - individual_square_sum)%mod) // 2)%mod
    return tmp
n = int(input())
lis = list(map(int,input().split()))
print(findProductSum(lis,n))
import numpy as np

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

# i = j
ij = np.sum(A_array * A_array)

Acum = np.sum(A_array)

temp = 0
for i in A:
    temp += i*Acum

ans = (temp - ij)/2

print(int(ans) % (10**9 + 7))
# C - Sum of product of pairs
import numpy as np

N = int(input())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7
A = np.array(A)
csA = np.zeros((N+1), dtype=object)
for i in range(N):
    csA[i+1] = csA[i] + A[i]
    
ans = 0
for i in range(N-1):
    ans += (A[i] * (csA[N] - csA[i+1])) % MOD
print(ans%MOD)
import numpy
n=input()
l=list(map(int, input().split()))
res=0
#print(f"le{len(l)}")
l.append(0)
l.reverse()
for i in range(len(l)): 
    print(l[len(l)-1-i],numpy.cumsum(l)[len(l)-i-2])
    res+=l[len(l)-1-i]*numpy.cumsum(l)[len(l)-i-2]
    #print(f"{res}レス")
print(res%(10**9+7))
#print(res)
l_len = int(input())
l_num = list(map(int,input().split()))

sq_sum_num = sum(l_num)**2
sq_list = [i**2 for i in l_num]
sq_sum_taikaku = sum(sq_list)
totals = int(((sq_sum_num - sq_sum_taikaku)/2))
total_v = totals % (10**9+7)
print(int(total_v))
import numpy as np
n=int(input())
t=np.array(input().split(' '))
num=np.zeros(n)
for a in range(n):
  num[a]=int(t[a])
x=0
for a in range(n-1):
  x+=num[a+1]*np.sum(num[0:a+1])
x=x%((10**9)+7)
print(int(x))
N = int(input())
A = [int(x) for x in input().split()]
 
partial_sum = A.copy()
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = int((sum_now+A[j])%(1e9+7))
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1])%(1e9+7)) %(1e9+7)
print(int(res))
input()
lis = list(map(int,input().split()))
def sol(lis):
    s = [0]*len(lis)
    x = 0
    for i in range(len(s)-1,-1,-1):
        s[i] +=x
        x +=lis[i]
    res = 0
    for i in range(len(lis)):
        res += lis[i]*s[i]
    print(res)
sol(lis)
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
  for j in range(n):
    b.append((a[i] % (10 ** 9 + 7)) * (a[j] % (10 ** 9 + 7)))
print(sum(b))
MOD = 10**9+7

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

N = int(input())
a = [int(_) for _ in input().split()]
print(int(findProductSum(a, N)))
import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)
A_sq = np.square(A)

print(int(np.mod(((A.sum())*(A.sum())-A_sq.sum())/2, 10**9+7)))
MOD = 1000000007

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

s = 0
r = 0
for a in A:
    s = (s + a)
    r = (r + a ** 2) % MOD

print(int(((s * s - r) % MOD) / 2))
N = int(input())
data = list(map(int, input().split()))
sum = 0

for i in range(N):
  for j in range(i+1,N):
    sum += (data[i]*data[j]) % (1000000007)
print(sum)
##C - Sum of product of pairs
N = int(input())
A = list(map(int,input().split()))
import itertools
B = list(itertools.combinations(A,2))
print(sum (list(map(lambda x: x[0] * x[1], B))) )
import numpy as np

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

A = np.array(A)
MOD = 10**9 + 7

ruisekiwa = np.zeros(N, dtype='int')
for i in range(1, N):
    ruisekiwa[i] = ruisekiwa[i-1] + A[i]

res = 0
for i in range(N-1):
    # res += np.sum(np.mod(A[i] * A[i+1:], MOD))
    res += (ruisekiwa[N-1] - ruisekiwa[i]) * A[i]
    res = res % MOD
print(res % MOD)

# FIXME TLE
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())

MOD = 10 ** 9 + 7
total = 0
s = sum(a)

for i in range(n):
    total += (a[i] * (s - a[i])) % MOD

print((total % MOD) // 2)
N = int(input())
A = list(map(int,input().split()))
x = 0
z = 0
MOD = 10**9 + 7
for i in A:
  x = (x%MOD + i%MOD)%MOD
  z = (z%MOD + i*i%MOD)%MOD
y = x*x%MOD
print((y-z)//2)
N = int(input())
A = list(map(int, input().split()))
ans=0
for i in range(N):
    ans+=(sum(A)-A[i])*A[i]
ans = ans / 2
print(int(ans%(10**9+7)))
import itertools
n = int(input())
a = list(map(int, input().split()))
amaria = []
ans = 0
p = 10 ** 9+7
#for i in itertools.combinations(a,2):
    #ans += i[0]* i[1]
    #print(ans)
for i in range(n):
    amaria.append(a[i]%p)
for j in itertools.combinations(amaria,2):
    ans += j[0]* j[1]
    print(ans)
n = int(input())
a = list(map(int, input().split()))
ans = 0
total = sum(a)
for i in range(n) :
    m = a[i]
    add = 0
    add += (total-m)*m / 2
    add %= (1e9)+7
    ans += add
ans %= (1e9)+7
print(int(ans))
n = int(input(''))
adl = input('')

a = list(map(int,adl.split(' ')))

number = 0

mod0 = 1000000000
mod1 = 7

amari = 0



for i in range(n):
    aa = 0
    for e in range(n-i-1):
        j = i+e+1
        if i != j:
            aa = aa + a[j]
    number = number + (a[i] * aa)
amari0 = number % mod0
amari1 = number % mod1
amari = amari0 + amari1
print(amari)
import numpy as np

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

A_array = np.array(A)[::-1]
A_cum = A_array.cumsum()[::-1]

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

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

line = input()
arr = [int(x) for x in line.split(" ")]

post = [0 for x in range(num)]
post[num - 1] = arr[num - 1]

for i in range(2, num + 1):
  post[num - i] = post[num-i+1] + arr[num - i]
  
sum = 0

for i in range(num-1):
  sum += arr[i] * post[i+1]
  #sum %= 1e9 + 7

sum %= 1e9 + 7
print(int(sum))
n=int(input())
l=list(map(int,input().split()))
s=0
for i in range(0,n):
  x=l[i%n]*l[(i+1)%n]
  s=s+x
print(s)
import itertools

def NextInts(): return map(int,input().split())

saisyo = input()
X = NextInts()
p = itertools.combinations(X, 2)
ANSWER = 0
MOD = 10**9+7
for i in p:
	answer = (int(i[0])%MOD*int(i[1])%MOD)
	ANSWER+=answer
print(ANSWER)
N = int(input())
A = list(map(int, input().split()))
mod = 1e9+7
S = 0
for i in range(N):
    S += A[i]

sum = 0
for i in range(N):
    S -= A[i]
    if S<0:
        S+= mod
    sum += int(A[i]*S%(1e9+7))
    

sum = int(sum%(1e9+7))    
print(sum)
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
ans = 0
Asum = [0 for _ in range(N)]
Asum[0] = A[0]
for i in range(1,N):
  Asum[i] = Asum[i-1] + A[i]
for i in range(N-1):
  ans += (A[i]*(Asum[N-1] - Asum[i]))%(10**9+7)
print(ans%(10**9+7))
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
f = sum(a)
ans = 0
for i in range(n):
  e = f-a[i]
  ans+= ((e*a[i])%mod)
  ans%=mod
print(ans//2)
N = int(input())
As = list(map(int,input().split()))

out = int((sum(As)**2 - sum([a**2 for a in As]))/2)
print(out % (10**9+7))
N=int(input())
A=list(map(int,input().split()))
Amap=map(lambda x:x%1000000007,A)
def selfmult(x):
    return (x%1000000007)**2
dot=((sum(Amap)%1000000007)**2-sum(map(selfmult,A)))/2
print(int(dot)%1000000007)
import numpy as np
from numba import njit, i8
import sys
read = sys.stdin.readline
mod = 10 ** 9 + 7


@njit((i8, i8[:]), cache=True)
def main(n, a):
    s = np.sum(a)
    ans = 0
    for i in range(n):
        ans = (ans + a[i] * (s - a[i])) % mod
    print(ans // 2)


n = int(read())
a = np.fromstring(read(), dtype=np.int64, sep=' ')
main(n, a)
n = int(input())
a = list(map(int,input().split()))
b=sum(a)
score=0
for i in range(len(a)):
  b -= a[i]
  score=a[i]*b
  
print(score)
n=int(input())
a=list(map(int,input().split(" ")))
print(int((sum(a)**2-sum([i**2 for i in a]))/2)%int(10**9+7))
n = int(input())
a = list(map(int,input().split()))
p = 10**9+7
ans = (sum(a)%p)**2
for i in range(n):
  ans = ans-(a[i]**2)
ans = ans/2
print(ans%p)
n=int(input())
l=list(map(int,input().split()))
b=sum(l)**2
a=0
for i in range(n):
    a+=l[i]**2
print((b-a)%(10**9+7)//2)
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=int(1e9)+7

###############################################################################\n=17
n=int(input())
A=INPUT()
sum=0
for i in range(n):
    sum+=A[i]
sum=sum*sum

s=0
for i in range(n):
    s+=A[i]**2

ans=(sum-J)//2
ans%=J
print(ans)
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
S = 0
for i in range (n):
    S += a[i] * (s-a[i])
S = S/2
ans = S%(10**9+7)
print(int(ans))
n = int(input())
an = list(map(int,input().split()))

mod = 10**9 + 7
total =sum(an)
ans = 0

for x in range(n-1):
  nokori = total-sum(an[:x+1])
  ans += an[x] * nokori % mod

    
    
print(ans)
import numpy as np
n=int(input())
t=np.array(input().split(' '))
num=np.zeros(n)
for a in range(n):
  num[a]=int(t[a])
a=np.sum(num)**2
b=np.sum(num**2)
x=int((a-b)/2)
if x<10**9+7:
  print(x)
else:
  x=x%(10**9+7)
  x-=1
  print(x)
import math
from fractions import Fraction as frac

MOD = 1e9 + 7

def solve(case_no):
    n = int(input())
    a = list(map(int, input().split()))
    ps = [a[0]]
    for i in range(1, n):
        ps.append(ps[i - 1] + a[i])
    ans = 0
    for i in range(n - 2, -1, -1):
        ans += a[i + 1] * ps[i]
        ans %= MOD
    print(ans)

t = 1
# t = int(input())
for i in range(1, t + 1):
    solve(i)
import numpy as np

N = int(input())
A = list(map(int, input().split(" ")))
mod_num = 1e9 + 7

sum_lst = sum(A)

sum_tmp = 0
for i in range(N):
    sum_tmp += (((sum_lst - A[i])%mod_num)*(A[i]%mod_num))
    sum_lst = sum_lst - A[i]

print(int(sum_tmp%mod_num))
N = int(input())
A = map(int, input().split())

ans = 0
mod = 10**9+7

S = sum(A)
S2 = sum(map(lambda x: x*x, A))

print((S*S-S2)//2 % mod)
n = int(input())
a = list(map(int, input().split()))

MOD = 10**9 + 7
s = 0
for i in a:s+=i

ans = 0
for i in a:
    ans += ((i*s)-(i*i))/2
    ans = ans % MOD

print(int(ans))
n=int(input())
arr = list(map(int,input().split()))

sum1=0
sum2=0

for i in arr:
    sum1+=i
    sum2+=i**2

x=((sum1**2)%(10**9+7) - sum2%(10**9+7))%(10**9+7)

x=x//2
print(x)
n = int(input())
item = [int(i) for i in input().split()]
mod = 10**9+7
ans = sum(item)**2/2 - sum([i**2/2 for i in item])
print(int(ans) % mod)
N = int(input())
l = list(map(int, input().split()))
import itertools
sum = 0
for p in list(itertools.combinations(l, 2)):    
    if p[1] != p[0]:
        sum+= (p[0] * p[1])

r = sum % (10**9 + 7)
print(r)
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    ans += a[i] * sum(a[i + 1 :n])
print(int(ans % (float('1e9') + 7)))
import copy
N=int(input())
list1=list(map(int,input().split()))

list2=copy.copy(list1)

x=0
for i in list1:
    for j in list2:
        if i<j:
            x=x+i*j
        else:
            continue

x=x%(10**9+7)
print(str(x))
from collections import deque
import sys, copy, itertools,heapq
input = sys.stdin.readline

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

suma = sum(A)
a = (suma ** 2)

b =0
for i in range(n):
  b += A[i]*A[i]

ans = a-b
if ans < 0:
  ans += 10**9 +7

answer = ans/2
answer = answer%(10**9 +7)

print(int(answer))
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n-1):
  for j in range(n-i-1):
    cnt+=a[i]*a[j+1]
print(cnt)
N=int(input())
A=list(map(int, input().split()))
count=0
S=0
while 1:
  for i in range(N):
    if count+1+i<N:
      S=S+A[count]*A[count+1+i]
  count=count+1
  if count==N:
    break
print(S)
x=int(input())
A=input().split()
n=len(A)
array_sum = 0
for i in range(0, n, 1): 
    A[i]=int(A[i])
    array_sum = array_sum + A[i]
array_sum_square = array_sum * array_sum
individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum += A[i] * A[i]
print( int((array_sum_square - individual_square_sum) / 2) %1000000007 )
def main():
    N = int(input())
    A = list(map(int, input().split()))

    mod = 10**9 + 7

    tmp = [0] * N

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

    print(tmp)

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

    print(ans % mod)


if __name__ == '__main__':
    main()
import numpy as np
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
a = np.array(a)
sum_a = np.sum(a)
sum_a2 = np.sum(a**2)

ans = (((sum_a*sum_a)-sum_a2)//2)%mod
print(ans)
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7

ans = 0

for aa in a:
  ans += aa
  ans %= mod
ans *= ans
ans %= mod
for aa in a:
  ans -= aa*aa
  ans %= mod

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

LA = len(A)
print(N)
print(A)
i = 0
j = 0
SUM = 0

for i in range(LA):
    for j in range(LA):
        if j <= i:
            continue

        SUM = SUM + (A[i] * A[j])


        
print(SUM % 1000000007)
import sys
 
def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split(" ")))
 
    mod = 10**9+7
    res = 0

    for i in range(N-1):
        for j in range(i, N):
            if i >= j: break
            res += A[i] * A[j]
    print(res % mod)
if __name__ == "__main__":
    main()
n = int(input())
a = list(map(int,input().split()))

mod= 10**9+7

A = sum(a)

ans=0

for i in a:
  ans += (A-i)*i %mod
print(ans//2%mod)
def square(list):
    return [i ** 2 for i in list]
m = 1000000007
n = int(input())
A = list(map(int, input().split()))
sq = square(A)
s1 = sum(A)
s2 = sum(sq)

result = (s1**2-s2)/2
print(round(result%m))
#Worst Solution
input()
l = list(map(int,input().split()))
r = 0
s = l
for i in range(len(l)):  
  for j in range(i+1,len(s)):
    r+=l[i]*l[j]
print(r)
N = int(input())
As = list(map(int,input().split()))

out = (sum(As)**2 - sum([a**2 for a in As]))/2
string =  str(out % (10**9+7))
print(string[0:len(string)-2])
n = int(input())
a = tuple(map(int,input().split()))
b = sum([(i**2) for i in a])
print(int(((sum(a)**2-b)/2)%(10**9+7)))
mod = 1e9 +7
n = int(input())
a = list(map(int,input().split()))
pref=[0 for x in range(n)]
pref[0] = a[0]
for i in range(1,n):
    pref[i] += ((pref[i-1]+a[i])%mod)
ans=0
for i in range(n-1,0,-1):
    ans += (a[i]*pref[i-1])
    ans %= mod
print(int(ans))
n = int(input())
a = list(map(int, input().split()))
k = 0
num = sum(a)
import math

for i in range(n):
    k = k + (a[i] * num) - (a[i] ** 2)

x = (k / 2) % ((10 ** 9) + 7)
print(math.floor(x))
N = int(input())
A = list(map(int, input().split()))


A_sum = 0
for i in range(0, N, 1):
    A_sum = A_sum + A[i]

A_sum_sq = A_sum * A_sum

idv_sq_sum = 0
for i in range(0, N, 1):
    idv_sq_sum += A[i] * A[i]

Answer = (A_sum_sq -
          idv_sq_sum) / 2
if Answer > 10**9:
    print(int(Answer % (10**9+7)))
else:
    print(int(Answer))
N = int(input())
A = list(map(int, input().split()))

ans = 0

for i in range(N):
    for j in range(i+1,N):
        ans += A[i] * A[j]

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

res = numpy.cumsum(A)

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

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

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

S = 0

for i in range(N-1):
  for j in range(i+1, N):
    S += numbers[i]*numbers[j]
    
print(S)
import numba
from numba import njit, b1, i4, i8, f8
import numpy as np  # noqa

N = int(input())
A = np.array([int(x) for x in input().split()], dtype=np.int32)
s = 0
for i in range(N):
    s += A[i]
    s %= 10**9 + 7


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


print(main(A, s))
n = int(input())
a = list(map(int,input().split()))
b = sum(a)**2
for i in range(n):
    b -= a[i]**2
print(int(b%(10**9+7)/2))
M = 1e9 + 7

def findProductSum(A, n): 

    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 

    array_sum_square = array_sum * array_sum 

    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 

    return int(((array_sum_square - individual_square_sum) // 2)%M)

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

print(findProductSum(A,n))