peterverebics/CodeNet_Python_118 huggingface dataset:
from sys import exit, stdin

input = stdin.readline
import copy

# from collections import deque,Counter
# import numpy as np

nmod = 1e9 + 7

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

ans = 0
tsum = 0
for i in range(N - 1, 0, -1):
    tsum += A[i]
    if tsum > nmod:
        tsum %= nmod
    ans += A[i - 1] * tsum
    if ans > nmod:
        ans %= nmod

print(int(ans))
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]

while s >= 2*(10**9 +7):
  s = s % 2*(10**9 +7)
s = s/2
 
print(int(s))
n=int(input())
arr=list(map(int, input().rstrip().split()))
start=0
sm=0
for i in range(start,n-1):
  for j in range(start+1,n):
    sm+=(arr[i]*arr[j])
  start+=1
print(sm)
N = int(input())
A = [int(e) for e in input().split()]
sum = 0
for i in A :
    for j in A:
        if i == j : continue
        sum = sum + i*j
print(sum%1000000007)
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(result%m)
import numpy
n = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 +7
x = numpy.array(a)
result = ((x.sum()**2 - x.dot(x)) // 2)%MOD
        
print(result)
n = int(input())
a = list( map( int, input().split() ) )

p = 0
for i in range(n):
  p += a[i] ** 2

print(int( ((sum(a) * sum(a) - p)/ 2 ) )% (10**9+7))
S = int(input())
A = [int(x) for x in input().split()]

print("A:",A)

Sum = 0
Asum = sum(A) % 1000000007
for i in range(len(A) -1 ):
    b = A[i]
    Asum = Asum - b
    if Asum < 0:
        Asum = Asum + 1000000007
    Sum = (Sum + Asum * b) % 1000000007

print(Sum)
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
import re
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

n=int(input())
a=[int(x) for x in input().split()]

ans=0;
for i in range(n):
    for j in range(i+1,n):
        if a[j]>a[i]:
            ans+=i*j
            ans%=mod
        
print(ans)
N = int(input())
A = list(map(int, input().split()))


sum_a = sum(A)
ans = 0

for a in A:
    sum_a -= a
    ans += sum_a * a

print(int(ans % (1e9+7)))
n=int(input())
a = list(map(int,input().split()))
def p(val):
    print(val)
 
sho = 10**9 +7
a1 = sum(a)**2
b1 = list(map(lambda y:y**2,a))
b2=sum(b1)
result = ((a1-b2)/2)% sho
p(result)
N = int(input())
A = list(map(int, input().split()))

# ans = 0

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

# div, mod = divmod(ans, 1000000007)

# print(mod)

ans = 0
x = 0

for a in A:
    ans = (ans + a * x) % (10e9+7)
    x = (x + a) % (10e9+7)

print(int(ans))
#!/usr/bin/env python3
N = int(input())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7

s = ((sum(A) % mod) ** 2) % mod



a = 0
for i in A:
    a += (i ** 2) % mod
    a = a % mod
if s - a < 0:
    s += 10**9 + 7
ans = (s - a) // 2
if ans < 0:
    ans += 10 ** 9 + 7
else:
    ans = ans % mod
print(ans)
MOD = pow(10, 9) + 7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    taikaku = 0
    for i in range(N):
        taikaku += pow(A[i], 2)
        taikaku %= MOD
    zennbu = 0
    sumA = sum(A)
    for i in range(N):
        zennbu += A[i]*sumA
        zennbu %= MOD
    ans = ((zennbu - taikaku) % MOD)//2
    print(ans)

if __name__ == "__main__":
    main()
import numpy as  np
mod = 1000000007
n = int(input())
a = list(map(int,input().split()))
ans = 0
s = np.zeros(n)
s[0] = a[0]
for i in range(1,n):
    s[i] = s[i-1]+a[i]

for i in range(n-1):
    ans += int((s[n-1]-s[i])*a[i]%mod)
    ans  = int(ans%mod)
print(ans)
def solve():
  N = int(input())
  AA = list(map(int,input().split()))

  ans = 0
  for a in AA:
    ans += a
  ans = ans % (10**9+7)
  ans = ans**2
  ans = ans % (10**9+7)
  for a in AA:
    aa = a**2
    aa = aa % (10**9+7)
    ans -= aa
  ans = ans % (10**9+7)
  if ans<0:
    ans += 10**9+7
  print(int(ans/2))
solve()
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 (array_sum_square - individual_square_sum) / 2


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

print(int(findProductSum(a, n) % (1e9 + 7)))
N=int(input())
A=list(map(int,input().split()))

mod=10**9+7

sumA=sum(A)%mod

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

ans=ans//2
print(ans%mod)
import numpy as np

N = int(input())
A = [int(i) for i in input().rstrip().split()]
A = np.array(A)
sum = 0

for i in range(N):
  sum += A[i]*np.sum(A[i+1:N])

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

mod=10**9+7

sumA=sum(A)%mod

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

ans=ans//2
print(ans%mod)
size = int(input())
arr = [int(i) for i in input().split()]

sum=0;
for i in range(0, size):
  for j in range(i+1, size):
    sum = sum + int(arr[i])*int(arr[j])
  

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

mod = 10**9 + 7

a_sum = sum(a_list)

ans = 0
for i in range(0, n):
    ans += (a_list[i] * (a_sum - a_list[i]))
# print(int((ans%mod)/2))
print(int((ans/2%mod)))
import sys
import numpy as np

readline = sys.stdin.readline
read = sys.stdin.read
MOD = 10**9 + 7

n = int(input())
a = np.array(readline().split(), dtype=np.uint64)
r = np.cumsum(a[::-1])[::-1]
r &= MOD
x = a[:-1] * r[1:]
x %= MOD
ans = int(np.sum(x) % MOD)
print(ans)
N = int(input())
AA = list(map(int,input().split()))

ans = 0
for a in AA:
  ans += a
ans = ans**2
for a in AA:
  ans -= a**2
ans = ans % (10**9+7)
print(int(ans/2))
N = int(input())
line = list(map(int, input().split()))
a = 10**9 +7
total = sum(line)%a
output = total**2 %a
for i in range(N):
    output = (output - (line[i]**2)%a)%a
print(int(output/2))
n=int(input())
a=input().split(' ')
b=[]
for x in a:
    b.append(int(x))
su=0
for t in b:
    su+=t
    
su=su*su
pas=0
for t in b:
    pas+=t*t
er=su-pas
er/=2
print(int(int(er)%1000000007))
import numpy as np

n = input()
a = list(map(int, input().split()))
#len_a = len(a)
#range_a = range(len_a)
times1 = []
times2 = []

for i, v in enumerate(a):
    times1.append(v)
    times2.append(sum(a[i + 1 : ]))

result = np.array(times1, dtype = "uint64") * np.array(times2, dtype = "uint64")

print(int(sum(result) % (10 ** 9 + 7)))
from sys import exit, stdin

input = stdin.readline
import copy

# from collections import deque,Counter
# import numpy as np

nmod = 1e9 + 7

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

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

print(int(ans))
N = int(input())
A = list(map(int,input().split()))
B = sorted(list(set(A)))
ans = 0
L = B.copy()
for i in range(-2,-len(B)-1,-1):
    L[i] += L[i+1]
for i in range(len(B)-1):
    ans += (B[i] * L[i+1]) % (10**9+7)
    if ans >= 10**9+7:
        ans = ans % (10**9+7)
print(ans)
N=int(input())
d=[int(s) for s in input().split()]
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        ans+=d[i]*d[j]
print(ans)
import itertools
import numpy as np

MOD = 1000000007
n = int(input())
ai = list(map(int,input().split()))
ans = 0

for v in itertools.permutations(ai, 2):
    print(v)
    ans += np.prod(v)
    
print(ans % MOD)
N = int(input())
A = list(map(int, input().split()))

sum = 0

for i in range(N - 1):
  for j in range(i , N):
    sum += A[i] * A[j]
    
ans = sum % (1.0e+9 + 7)

print(ans)
input()
a = list(map(int, input().split()))
c = 1000000007
print(((sum(a)**2-sum(map(lambda x: x**2, a)))/2)%c)
a = input()
import numpy as np
b = list(map(int,input().split()))
b = np.array(b)
m = 10**9 + 7
total = (sum(b)**2 - b.dot(b))/2

print(int(total%m))
n=int(input())
M=10**9+7
X=list(map(int, input().split()))

tot = 0
s_tot=0

for i in range(n):
    y=X[i]
    
    tot = (tot + y) %M
    #y_m= y ** 2 %M
    s_tot = s_tot + (y**2)
    #print(y,tot,s_tot)
ans = (tot**2 - s_tot)
if ans <0:
    ans+=M
ans = int(ans/2)
#ans = int( (tot**2 - s_tot) / 2) 
print(ans % M)
"""
if ans >= M:
    print(ans % M)
else:
    print((ans + M)% M)
"""
N = int(input())
li = list(map(int, input().split()))
MOD_NUMBER = 10**9+7
nizyo_list = [i**2 for i in li]
ans = int((sum(li)**2-sum(nizyo_list))/2)
print(ans % MOD_NUMBER)
N = int(input())
A = list(map(int, input().split()))

ans = 0
x = 0

for a in A:
    ans = (ans + a * x)
    x = (x + a)

print(int(ans % (1e9+7)))
N = int(input())
A = map(int,input().split())
ans = 0
ans2 = 0
mod = 10 ** 9 + 7
for a in A:
    ans += a
    ans2 += a**2
    ans %= mod 
    ans2 %= mod
print(((ans) ** 2 -ans2)//2)
mod = 10**9+7
n = int(input())
A = list(map(int,input().split()))
A.sort()
s  =sum(A)
ans = 0
for a in A:
    ans += a*(s-a)
    ans %= mod
ans //=2
print(ans%mod)
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.int64)
s = 0
for i in range(N):
    s += A[i]


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))
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 = sum(A) % (10**9 + 7)


@njit((i4[:], i4, ), cache=True)
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))
from itertools import combinations
num = int(input())
a = list(map(int, input().split()))
l = combinations(a, 2)
ans = 0
mod = 1000000007
for i in l:
  ans += ((i[0] % mod) * (i[1] % mod)) % mod
print(ans)
N = int(input())
A = list(map(int, input().split()))

sum = 0

for i in range(N - 1):
  for j in range(i + 1, N):
    sum += A[i] * A[j]
    
ans = sum % (1.0e+9 + 7)

print(ans)
import math
n = int(input())

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

diagSum = sum(list(map(lambda v: v ** 2, main)))

print(math.floor((sum(main) ** 2 - diagSum) / 2) % 1000000007)
_N = int(input())
_list = list(map(int, input().split()))
_list.sort()

_sum = 0
_answer = 0

print(_list)
for i in range(_N):
  for l in range (_N):
    if i < l:
      _sum += _list[i] * _list[l]

_answer = _sum % (10**9+7)
print(int(_answer))
MOD=10**9+7
N=int(input())
A=list(map(int,input().split()))
a_sum=sum(A)%MOD
ans=(a_sum**2)%MOD
ans-=sum(map(lambda x: x*x%MOD, A))%MOD
print(ans%MOD//2)
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
sum1=0
sum2=0
for i in range(len(A)):
    sum1+=A[i]
    sum1%=mod
for i in range(len(A)):
    sum2+=(A[i]%mod)**2
    sum2%=mod
ans=(((sum1**2)-sum2)%mod)/2
print(int(ans))
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,CONST)
    if s < 0: s += CONST
print(s//2)
N = int(input())
nums = list(map(int, input().split()))
 
def square(x):
  return x * x
 
out = (square(sum(nums)) - sum(map(square, nums))) / 2
 
print(int(out % (10**9 + 7)))
N = int(input())
A = list(map(float, input().split()))
S = sum(A)
result = 0
mod = 10 ** 9 + 7
for a in A:
  S -= a
  result += a * S
  result %= mod
print(result)
mod = 1000000007
N = int(input())
A = list(map(int,input().split()))
sum_a = sum(A)
ans = 0
for a in A:
    ans += a*(sum_a-a)
    #print(sum_a-a)
    ans %= mod
    
print(ans//2)
n=int(input())
a=list(map(int,input().split()))

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

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_cumsum = np.cumsum(As)
    ans = 0
    for i in range(1, n):
        ans += As[i] * As_cumsum[i-1]
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()
N = int(input())
A = list(map(int,input().split()))
mod = 1000000007
sum = 0
indsum = 0
for i in A:
  sum += i
  sum%=mod
  p = (i*i)%mod
  indsum+=p
  indsum%=mod
squaresum = (sum*sum)%mod
res = (((squaresum-indsum)%mod)//2)%mod
print(res)
N = int(input())
A = list(map(int, input().split()))
m = 10 ** 9 + 7

total_A = 0
for i in range(N):
    total_A = (total_A + A[i]) % m

total = (total_A * total_A) % m

total_sq = 0
for i in range(N):
    total_sq = (total_sq + A[i] * A[i]) % m

divide = total - total_sq
if divide < 0:
    divide += m

print(int(divide / 2))
from itertools import combinations
MOD = 1000000007
n=int(input())
a=list(map(int,input().split()))
sum=0
for x,y in combinations(a,2):
   sum+= x*y%MOD
print(sum)
def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans % (10**9+7)
  ans = ans**2
  ans = ans % (10**9+7)
  for a in AA:
    ans -= a**2
    ans = ans % (10**9+7)
  ans = ans % (10**9+7)
  if ans<0:
    ans += 10**9+7
  print(int(ans/2))
solve()
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

s = sum(a) % mod
ans = 0
for i in a:
    ans += ((s - i) % mod) * i
    ans %= mod
print(ans // 2)
n = int(input())
a = list(map(int, input().split()))
ans = 0

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

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

for i in range(n):
  sum = (sum+a[i])%m

#sum = sum%m
#sum = sum*sum
ans = 0
for i in range(n):
  ans = (ans + sum*a[i])%m
  ans = (ans - a[i]*a[i])%m
ans = int((ans/2)%m)

print(ans)
import numpy as np

n=int(input())
a_list=list(map(int,input().split()))
sum=0
ps=np.cumsum(a_list[::-1])[::-1] 
for i in range(n-1):
  sum+=a_list[i]*ps[i+1]

s=sum%(10**9+7)
print(s)
N = int(input())
A = [int(x) for x in input().split()]
ps = A.copy()
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = (sum_now+A[j])%(1e9+7)
    ps[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*ps[i+1])%(1e9+7)) %(1e9+7)
print(int(res))
n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in A:
    for j in A:
        ans += (i*j) % (10**9+7)
mi = sum([x ** 2 for x in A])
ans -= mi
ans = ans % (10**9+7)
print(int(ans/2))
import numpy as np

n=int(input())
a_list=list(map(int,input().split()))
sum=0
ps=np.cumsum(a_list)
for i in range(n-1):
  sum+=a_list[i]*(ps[n-1]-ps[i])

s=sum%(10**9+7)
print(s)
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
sum = A.sum()
sum2 = (A**2).sum()
ans = int(((A.sum())**2 - sum2)/2) % (10**9+7)
print(ans)
N = int(input())
A = input()

a = list(map(int, A.split(" ")))

cur_ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        print(str(i) + " " + str(j))
        cur_ans += a[i]*a[j]
        cur_ans = cur_ans % (1000000000 + 7)

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

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

ans = 0

B = list(itertools.combinations(A,2))

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

print(ans)
N = int(input())
A = map(int,input().split())
total=0
for i in range(N):
  try:
    sumA = A[i]*sum(A[i+1:])
    total+=sumA
  except:
    pass
print(total)
from itertools import combinations
N = int(input())
A = list(map(int, input().split()))

com_A = combinations(A,2)
ans = 0
MOD = 10**9 + 7
for x, y in com_A:
    ans = (ans + (x * y)) * MOD

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

N = int(input())
A = np.array([int(i) for i in input().split()])
sum = 0

#累積和だけは1項ずつ求めてmodをとる
for x in A:
  sum += x
  sum %= (10**9+7)
#sum = A.sum() % (10**9+7)

sum2 = 0
#for x in A:
#  sum2 += x*x
#  sum2 %= (10**9+7)
sum2 = (A**2).sum() % (10**9+7)

ans = (sum**2 - sum2) % (10**9+7)
if ans < 0:
  ans += (10**9+7)
ans *= int((10**9+7+1)/2) 
ans %= (10**9+7)
print(int(ans))
n=int(input())
num=input().split()
sq=[]
for i in range(n):
  num[i]=int(num[i])
  sq.append(num[i]*num[i])
total=sum(num)
total=total*total
sqtotal=sum(sq)
ans=(total-sqtotal)/2
print(int(ans%1000000007))
import numpy as np
N=int(input())
A=list(map(int,input().split()))
A=np.array(A)

a=int((np.sum(A)**2-np.sum(A**2))/2)
print(a%(10**9+7))
modulo=10**9+7
N=int(input())
array=[int(x) for x in input().split()]
total=((sum(array))**2)%modulo
for i in array:
	total=(total-i**2)%modulo
print((total//2))
MOD = 10 ** 9 + 7

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

ans = 0
ans = sum(a) * sum(a) % MOD
ans -= sum(map(lambda x:x * x,a)) % MOD
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + MOD) // 2)
def findProductSum(A, n):
    tmp = (10**9)+7

    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]
        individual_square_sum = individual_square_sum

    return ((array_sum_square - individual_square_sum) // 2) % tmp

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

print(float(findProductSum(a,n)))
import itertools
N = int(input())
a = list(map(int,input().split()))
ans = 0

total = sum(a)
for i in range(N):
    ans += a[i] * (total-a[i])
ans = int(ans/2)
print(ans%(10**9 + 7))
import numpy as np
N = int(input())
Sum = 0
A = list(map(int, input().split()))
B = np.cumsum(np.array(A))
for i in range(N):
    Sum += A[i]*(B[-1]-B[i])
print(Sum%(1000000000+7))
MODINT = 1000000007
n = int(input())
A = list(map(int,input().split()))
prodsum = [0]*n
prodsum[0] = A[0]
for i in range(1,n):
    prodsum[i] = prodsum[i-1]+A[i]
# print(prodsum)
ans = 0
for i in range(n-1):
    ans += A[i]*(prodsum[-1]-prodsum[i])
    ans % MODINT
print(ans)
def main():

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


    m = 10**9 + 7
    ans = 0
    s = sum(a)
    for i in a:
        tmp = (s - i) % m
        ans += tmp * i
    ans //= 2
    print(ans%m)

if __name__=='__main__':
    main()
import numpy as np

MOD = 10 ** 9 + 7

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

s=list(np.cumsum(alst))

sum=0

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

print(sum%MOD)
N = int(input())
A = list(map(int, input().split()))
result = 0
i = 0
for x in A[:N]:
  for y in A[i+1:]:
    result += x * y
  i += 1

result = result % (10*9 + 7)
print(result)
n=int(input())
a=[int(x) for x in input().split()]
ans=0
for i in range(n-1):
    for j in range(1+i,n):
        ans+=a[i]*a[j]%(10**9+7)

print(ans)
m = 10**9 + 7
n = input()
a = list(map(int,input().split()))
ans = 0
s = sum(a)

for i in a:
  s -= i
  ans += s*i
  s += i

ans = ans%m

print(ans)
N=int(input())
A=list(map(int,input().split()))
C=[A[i]**2 for i in range(N)]
print(int((sum(A)**2-sum(C))/2%(10**9+7)))
n = int(input())
liste = list(map(int, input().split()))
liste.sort()
summ = 0
for i in range(0, len(liste)):
    for j in liste[i+1:n]:
        if liste[i] >= 1 and j <= n%(10**9)+7 and liste[i] < j:
            summ += liste[i] * j
print(summ)
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)
N = int(input())
As = list(map(int,input().split()))
sums = 0
moder = 1000000007
s=[0 for i in range(N-1)]
s[-1] = As[-1]
for i in range(N-2):
  s[-(i+2)] = s[-(i+1)]+As[-(i-2)]
for i in range(N-1):
  sums+= (As[i]*s[i])%moder
print(sums%moder)
n = input()
a_list = list(map(int, input().split()))
sum_ = 0
mod = 10 ** 9 + 7
for i in range(len(a_list) - 1):
  sum_ += ((a_list[i] % mod) * (a_list[i + 1] % mod)) % mod 
print(sum_ % mod)
n = int(input())
a = list(map(int,input().split()))
sum = 0

for i in range(n):
  sum += a[i]

sum = sum*sum
for i in range(n):
  sum -= a[i]*a[i]
sum = int(sum/2)
sum = sum%(10**9+7)

print(sum)
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)
total = ((sq_sum_num - sq_sum_taikaku)/2) % (10**9 + 7)
print(int(total))
N = int(input())
A = list(map(int, input().split()))

ans = 0
Q = 1e9 + 7

b = 0

for i in range(1, N):
    b += A[i-1]
    b %= Q
    ans += A[i] * b
    ans %= Q

print(int(ans))
N= int(input())
list1 =[]
list1 = list(map(int, input().split()))
sum = 0

print(list1)  
for i in range(N-1):
    for j in range(i+1,N):
        
        sum = sum + list1[i]*list1[j]
answer = divmod(sum, 10**9+7)
print(answer[1])
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
total = sum(a)
total %= mod
total = total ** 2
total %= mod
cnt = 0
for i in range(n):
  cnt += a[i]**2
  cnt %= mod

ans = total - cnt
ans %= mod
print(ans)
n = int(input())
a = list(map(int, input().split()))
 
s = 0
for i in range(n):
	for j in range(i+1, n):
		s += (a[i]% (10**9+7)) * (a[j]% (10**9+7))
		
print(s)
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

mod=1000000007
n = r()
a = rl()
b = [a[-1]]
for i in range(n-2,-1,-1):
    b.append(b[-1]+a[i])
b = b[::-1]
print(b)
ans = 0
for i in range(n-1):
    ans= (ans+(a[i]*b[i+1])%mod)%mod
print(ans)
import numpy as np

n = int(input())
a = input().split()
ai=np.array(a, dtype="int64")

div=(1E9+7)*2

#total=sum(ai)**2
#diagonal=sum(ai**2)
#ans=(total-diagonal)/2

totalmod=(sum(ai)%div)**2
diagonalmod=sum((ai**2)%div)
ansmod=totalmod-diagonalmod

if (ansmod <= 0):
  ansmod=ansmod+div

print(int((ansmod/2)%(1E9+7)))
N = int(input())
A = list(map(int, input().split()))

mod = 10**9+7

tmp = 0
for i in range(N):
    tmp += A[i]
    tmp = tmp % mod
all = (tmp % mod)**2
all = all % mod

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

tri = (all-di)//2

print(tri % mod)
N = int(input())
A = input().split()
S = 0
B = 0

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

print(int(( (sum(A)*sum(A)) - B ) % ( 10**9 + 7 ) / 2 ) )
N = int(input())
As = list(map(int, input().split()))
S = 0
T = 0
for i in range(N):
  S += As[i]
  T += As[i] * As[i]
print(int(((S*S - T) / 2))% 1000000007)
N = int(input())
 
A = list(map(int, input().split()))
 
c = 0
 
for i in range(N-2):
  for j in range(int(i)+1, N):
    d = A[i] 
    e = A[j] 
    c = (c + d*e) % (10**9+7)
    
    
 
c = c % (10**9+7)
 
print(c)
n = int(input())
a = list(map(int, input().split()))
sum = 0
t = n-1
for i in a:
    for j in range(t):
        sum += i * a[-(j+1)]
    t -= 1
ans = sum % (10**9 + 7)
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]
sumAcol=sumAcol % (10**9+7)
for i in range(N):
  sumA+=sumAcol*A[i]
sumA=(sumA-sumtr)/2

print(int(sumA % (10**9+7)))
n = int(input())
a = [int(x) for x in input().split()]

b = [0]
for i in range(1,n+1):
  b.append((a[i-1] + b[i-1]) % ((10 ** 9) + 7))
print(b)

ans = 0
for i in range(n):
  p = b[n] - b[i+1]
  p = a[i] * p % (10**9 + 7)
  ans += p
  print(ans,p)
print(ans)