peterverebics/CodeNet_Python_118 huggingface dataset:
from collections import deque

def main():
    import sys
    input = sys.stdin.readline

    MOD = 1000000007
    n = int(input())
    A = list(map(int, input().split()))
    tmp = sum(A)
    ans = 0
    for i in range(n-1):
        tmp -= A[i]
        ans += A[i]*tmp
    print(ans%MOD)

if __name__ == '__main__':
    main()
n = int(input())
a_int = list(map(int, input().split()))

squ = 0
num = 10 ** 9 + 7

a_sum = 0
for i_sum in range(1, n):
    a_sum += a_int[i_sum]

for i in range(0, n-1):
    squ += a_int[i] * a_sum
    a_sum -= a_int[i+1]

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

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

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

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

ans = ans % MOD
print(ans)
def LI():
    return list(map(int, input().split()))


N = int(input())
A = LI()
total = sum(A)
ans = 0
mod = pow(10, 9)+7
for i in range(N-1):
    total -= A[i]
    ans = (ans+total*A[i]) % mod
print(ans)
import sys
import math
def Ii():return int(sys.stdin.readline().rstrip())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))
n = Ii()
a = Li()
sa = 0
ans = 0
mod = 10**9+7
for i in range(n-1):
  sa += a[i]
  ans += sa*a[i+1]
  ans %= mod
  
print(ans)
N=int(input())
l=list(map(int,input().split()))
ans=0
i=0
S=sum(l)
while i<len(l)-1:
  S=S-l[i]
  ans+=l[i]*S
  i+=1
print(ans%1000000007)
if __name__ == "__main__":
	MOD = 10 ** 9 + 7
	N=int(input())
	A=list(map(int,input().split()))

	Asum = sum(A) % MOD

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

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

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

for j in range(N):
    sum_1 += (A[j]**2)%mod
sum2=sum-sum_1
if sum2<0:
    sum2+=mod
ans=(sum2*500000004)%mod
print(int(ans))
n = int(input())
a = list(map(int,input().split()))
p = 0
q = a[0]
for i in range(1,n):
    p += q*a[i]
    p %= 1000000007
    q += a[i]
    q %= 1000000007
print(p)
n=int(input())
a=list(map(int,input().split()))
x=(sum(a)-a[n-1])*(sum(a)-a[0])
print(x%(10**9+7))
import itertools

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

sum=0
mod = 1000000007
for v in itertools.combinations(A, 2):
    v0 = v[0]%mod
    v1 = v[1]%mod
    sum += v0*v1%mod
print(sum)
N = int(input())
A = list(map(int,input().split()))
x = 0
z = 0
MOD = 10**9 + 7
for i in A:
  x = (x + i)%MOD
  z = (z + i*i)%MOD
y = x*x%MOD
w = (y-z)//2%MOD
print(w)
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
s=sum(A)
ans=0
for a in A:
    ans += a*(s-a)
print((ans/2)%mod)
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())), dtype=np.int64)
mod = 10**9 + 7

sq_sum = (A*A).sum()
sum_sq = A.sum() * A.sum()
answer = (sum_sq - sq_sum) / 2

print(int(answer % mod))
N = int(input())
nums = list(map(int,input().split()))
sum = 0

for i in range(N):
  for j in range(N):
    if i == j or i > j :
      continue
    else:
      sum += nums[i]*nums[j]
      
print(sum%10**9+7)
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[0])
N = int(input())
A = [int(i) for i in input().split()]
su = 0

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

print(su)
N = int(input())
A = list(map(int ,input().split()))
MOD = 1e9+7

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

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

ans = ans % MOD
print(ans)
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 += (s[n-1]-s[i])*a[i]
    ans  = ans%mod
print(ans)
n=int(input())
arr=list(map(int,input().split()))
ss=0
s=0
for i in range(n):
    ss=ss+arr[i]**2
    s=s+arr[i]
ans=(s**2-ss)/2
print(int(ans%(10**9+7)))
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(int(result%m))
n = int(input())
p = input().split()
product = 0
for i in range(n): 
    for j in range(i+1,n): 
        product = product + int(p[i])*int(p[j]) 
print(product)
n = int(input())
a_s = list(map(int, input().split()))

ans = 0

for i in range(n):
    for j in range(i+1, n):
        ans += int(a_s[i] * a_s[j] % (1e9 + 7))

print(ans)
n = input()
a = list(map(int, input().split()))
s = 0

for i in a:
    for j in a:
        if i > j:
            s += i * j

print(s % (10 ** 9 + 7))
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
N = int(readline())
A = list(map(int,readline().split()))
total = sum(A)
B = [0] * N
for i in range(N):
    B[i] = total-A[i]
ans = 0 
for i in range(N):
    ans += A[i]*B[i]
    if ans >= 2*MOD:
        ans %= MOD
print(ans//2)
import math
N = int(input())
A = [int(num) for num in input().split()]

sumA = sum(A)
ans = 0
for i in range(len(A)):
    sumA = sumA - A[i]
    ans += A[i] * sumA
    ans = int(ans % (math.pow(10,9)+7))


ans = int(ans % (math.pow(10,9)+7))
print(ans)
N = int(input())
a = list(map(int, input().split()))
result = 0 
import numpy as np
num = np.array(a)
for i, a in enumerate(num):
    sum = np.sum(a*num[(i+1):])
    result += sum
if result >= (10**9 + 7):
    print(result % (10 ** 9 +7))
else:
    print(result)
n = int(input())
a = list(map(int, input().split()))
A = [0]*(n)
num = 1e9+7
ans = 0
for i in range(1, n):
    A[i] = A[i-1] + a[i-1]
for i in range(n-1, 0, -1):
    ans += (A[i]*a[i])%num
    ans = ans%num
print(int(ans))
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 = (ans + a[i]*pref[i-1])%mod


print(int(ans))
# -*- coding: utf-8 -*-


# 整数の入力
n = int(input())
# スペース区切りの整数の入力
zzz = list(map(int, input().split()))
b=sum(zzz)**2
a=0
for i in range(n):
  # print(i)
  x=zzz[i]**2
  print(x)
  a +=x
# print(b)
# for a in zzz:
#   print(a)

# print(b)
# print(a)

ans = (b-a)//2%(10**9+7)
print(ans)
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(int(ans))

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

for i in itertools.combinations(a,2):
    if i[0]==i[1]:
        continue
    else:
        s+=i[0]*i[1]

print(s%(10**9+7))
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**2)%mod
t=0
for x in a:
	t= (t+ x**2)%mod
ans=((((s-t)%mod+mod)%mod)//2)
print(ans%mod)
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)
x=(x-1)%(10**9+7)
print(x)
N = int(input())
A = list(map(int,input().split()))
mod = 1000000000 + 7
S = sum(A)
S2 = sum(map(lambda x: x*x%mod,A))
ans = ((S*S - S2)/2)%mod
print(int(ans))
n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)-1):
    if lst[i] not in d_lst:
        if lst[i] == lst[i+1]:
            d_lst.append(lst[i])
for d in d_lst:
    count += d**2
lst = list(set(lst))

for i in range(len(lst)-1):
    for j in range(i+1,len(lst)):
        a = lst[i] * lst[j]
        count += a

if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)
N = int(input())
A = list(map(int, input().split()))


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

ans = (((B**2) - C) / 2) % (10 ** 9 + 7)
print(int(ans))
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
  
print(int(sum))
N = int(input())
A = input().split()

ss = 0
for i in range(N - 1):
    j = i +1
    ss += int(A[i]) * int(A[j])
ss += int(A[N -1])
print(ss % 1000000007)
import numpy as np
n = int(input())
a = list(map(int,input().split()))
a_sum = sum(a)
aa = np.array(a)
aaa = np.cumsum(aa)
aaa = aaa
all_a = sum(a)

ans = 0
for i in range(n-1):
    ans += (a[i]%(10**9+7) * (all_a - aaa[i]))

print(ans%(10**9+7))
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**2
pas=0
for t in b:
    pas+=t*t
er=su-pas
er/=2
print(int(er%1000000007))
def solve(N, As):
    total = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            total += As[i] * As[j]
    ans = total % (9 ** 9 + 7)
    print(ans)


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split()))
    solve(N, As)
import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)
A_sq = np.square(A)
Ans = ((A.sum())**2 - A_sq.sum()) // 2 % (10**9+7)
print(Ans)
def productSum(A,n) -> int:
    MOD = 1000000007
    sum_arr = 0
    for i in range(n):
        sum_arr += A[i]
        sum_arr %= MOD
    sum_arr_sq = (sum_arr*sum_arr)%MOD
    indiv_sq_sum = 0
    for i in range(n):
        indiv_sq_sum += (A[i]*A[i])
        indiv_sq_sum %= MOD
    ans = ((sum_arr_sq - indiv_sq_sum))//2
    ans %= MOD
    return ans

n = int(input())
arr = [int(x) for x in input().split()]
print(productSum(arr,n))
N=int(input())
A=list(map(int, input().split()))
p=10**9+7
S=sum(A)
S2=S**2
T=0
for i in range(N):
    T+=A[i]**2
ans=((S2-T)//2)%p
print(ans,S2)
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
  for a in AA:
    ans -= a**2
  ans = ans % (10**9+7)
  while ans<0:
    ans += 10**9+7
  print(int(ans/2))
solve()
# coding: utf-8
# Your code here!

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

sum = 0
B = []
B.append(0)

for t in range(N):
    B.append(A[t] + B[t])
    
B.remove(0)
    
print(B)
    
for i in range(N):
    sum += A[i] * (B[N-1] - B[i])
            
        
print(sum % (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), np.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)
N = int(input())
A = list(map(int,input().split()))

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

print((S*S - S2) / 2 % 1000000007)
mod = pow(10, 9) + 7
n = int(input())

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

sq = sum([x**2 for x in lt])
st = sum(lt)**2
ans = (st - sq + mod)%mod
ans = (ans/2)%mod
print(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 % (10**9 +7)
if s >= 10**9 + 7:
  s = s % (10**9)
s = s/2
 
print(int(s))
n = int(input())
l = list(map(int,input().split()))
M = 1000000007
sm = 0
for i in l:
	sm = (sm + i)
sms = pow(sm,2,M)
ss = 0
for i in range(n):	
	ss = (ss + (l[i] * l[i]))
print(((sms - ss)//2)%M)
a=int(input())
b = list(map(int, input().split()))
b.sort()
S=0
c=sum(b)
for i in range(0,a):
    S=S+b[i]*(c-b[i])
print(S % (10**9+7))
n = int(input())
A = list(map(int, input().split()))

ans = 0
mod = 1e9 + 7

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

print(int(ans % mod))
import numpy as np
def main():
  m=1000000007
  n=int(input())
  a=np.array(list(map(int,input().split())))
  b=np.flipud((np.cumsum(np.flipud(a)))[:-1])
  a=a[:-1]
  c=a*b
  d=np.sum(c)
  e=d%m
  print(e)
main()
N = int(input())
A = [int(x) for x in input().split()]

mod = 10**9 + 7
x = sum(A)
y = x**2 - sum([x**2 for x in A])
print(int(y / 2) % mod)
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=[0]
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)
mod = 1000000007

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    for i in range(N - 1):
        ans += (A[i] * sum(A[i + 1:]) / mod)
    print(ans % mod)

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

if N == 2:
    print((A[0]*A[1])%(10**9+7))
B = [0]*(N-1)
B[N-2] = A[N-1]

for i in range (3, N+1):
    B[N-i]=B[N-i+1]+A[N-i+1]

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

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

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

ans = sum(A)^2

for a in A:
  ans -= a^2

ans /= 2

print(int(ans%(10^9+7)))
n=int(input())
a=list(map(int,input().split(" ")))
print(int((sum(a)**2-sum([i**2 for i in a]))/2)%(10**9+7))
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) % mod
    q = sum([a ** 2 % mod for a in A]) % mod
    ans = (((s * s) % mod - q) % mod) / 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()
n=int(input())
arr=list(map(int, input().split()))
m=[]
for i in range(n):
  for j in range(n):
    if (arr[i]==arr[j]):
      pass
    elif ((arr[i]*arr[j]) in m):
        pass
    else:
      m+=[(arr[i]*arr[j])]
      
print(sum(m))
N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = 1e9 + 7
s = sum(A) % mod

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

s = sum(a)
aa = sum(list(map(lambda x: x**2, a)))

total = int((s**2 - aa) / 2) % (10**9 + 7)
print(total)
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst,dtype='float32')

sum=0

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

print(sum%MOD)
n = int(input())
intlist = list(map(int,input().split()))
mod = 1000000007

sum = 0
for i in range(n):
  sum += intlist[i]
  sum %= mod

ans = sum*sum%mod

for i in range(n):
  ans -= intlist[i]*intlist[i]%mod
  if ans < 0:
    ans += mod

ans *= (mod+1)/2
ans %= mod
print(int(ans))
import numpy as np
N = int(input())
As = np.array(list(map(int, input().split())))
m = 10**9 + 7
result = 0
a = (As.sum() ** 2)
b = (As ** 2).sum()
print(int(((a - b)/2)%m))
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(S)
# print(T)
A = S*S % 1000000007
B = T % 1000000007
print(int(((A - B) % 1000000007) / 2) % 1000000007)
import numpy as np
n = int(input())
s = 0
a = np.array(list(map(int, input().split())))
for i in range(len(a)-1):
  s_tmp = np.sum(a[i+1:len(a)])
  s += a[i] * s_tmp
print(s % 1000000007)
import sys
import numpy as np
import math
import collections
import copy
import decimal
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

N = int(input())
An = list(map(int, input().split()))
An_s = collections.Counter(An)
total = 0
for k in An_s:
    total += k
tt = sum(An)
ans = 0
for A, v in An_s.items():
    if v == 1:
        At = A * (tt-A)
    else:
        At = A * (total-A)*v
#     print(A, v, total, At, ans)
    ans = (ans+At) % (10**9+7)
#     print(ans)
print(ans//2)
N = int(input())
A = [int(e) for e in input().split()]

S = [0]
sum =0
for i in range(0, N):
    S.append(S[i] + A[i])
for i in range(N):
    sum = sum + (S[i+1]-A[i]) * A[i]
print(sum)
n = int( input() )

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

Sum = 0


for i in range(n):
	for j in range(i,n):
		Sum = Sum + i*j

print(Sum)
def main():
    MOD = 10**9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    a_sum = sum(a)
    ans = 0
    
    for i in range(n):
        ans += a[i] * (a_sum - a[i])
        ans %= MOD
    print(ans//2)
        
        
if __name__ == '__main__':
    main()
n=int(input())
a=list(map(int,input().split()))
if n==1:
  print(a[0])
else:
  l=list(map(lambda z:z**2,a))
  x=sum(a)
  y=sum(l)
  t=(x-y)//2
  print(t)
import sys
n = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7
ans = 0
# for i in range(n-1):
#     for j in range(i+1,n):
#         ans += A[i]*A[j]
#         ans %= mod
sum = 0
for i in A:
    sum += i
sum %= mod    

ans = sum * sum
for j in A:
    ans -= j * j
    ans %= mod
ans //= 2    

print(ans)
n=int(input())
*a,=map(int,input().split())
s=sum(a)%(10**9+7)
c=0
for i in range(n):
    amod=a[i]%(10**9+7)
    c+=(s-amod)*amod
print(c%(10**9+7)//2)
n=int(input())
hoge=list(map(int,input().split()))
ans=0
wa=hoge[0]
for i in range(1,n):
  ans+=wa*hoge[i]
  wa+=hoge[i]
print(ans)
n=int(input())
inf=10**9+7
a=list(map(int,input().split()))
import numpy as np
arr_a=np.array(a)
s=np.sum(arr_a)
norm=np.sum(arr_a**2)
x=(s**2-norm)//2
print(x-(x//inf)*inf)
def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    mod = 10**9+7
    s = 0
    sq = 0
    for i in range(n):
        s += a[i]
        sq += (a[i])**2
        s %= mod
        sq %= mod

    s2 = (s**2) %mod
    ans = s2-sq
    if ans < 0:
        ans += mod
    print((ans//2)%mod)
resolve()
N=int(input())
A=list(map(int, input().split()))
MOD=7+10**9
ans=0
for i in range(len(A)-1):
    for j in range(i+1,len(A)):
        print(A[i],A[j])
        ai= A[i] % MOD
        aj=A[j] % MOD
        ans = ans +ai*aj % MOD
print(ans%MOD)
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
re = 0
re2 = 0

for i in range(n):
    re = a[i]*sum(a[i+1:])
    #for m in range(n-i-1):
        #re = a[i]*a[i+m+1]
        #re2 += re

ans = re %1000000007
print(ans)
N = int(input())
ls = list(map(int, input().split()))
 
size = len(ls)
 
ans = 0
for i in range(size - 1):
  gou = sum(ls[i+1:size])
  ans = ans + (gou * i)%1000000007
 
print(ans % 100000007)
N=int(input())
A=list(map(int,input().split()))
num=0
for i in range(N):
    num+=A[i]**2
print(int(((sum(A)*sum(A)-num)/2)%1000000007))
n = int(input())
l = input()
a = l.split(' ')

tmp = 0
tmp2 = 0

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

for i in range(n):
    tmp2 += int(a[i])*int(a[i])

#total = int((tmp*tmp-tmp2)/2)

print(int(((tmp*tmp-tmp2)/2)%1000000007))
import numpy as np
N = int(input())
numbers = np.array(list(map(int, input().split())))
mod = 1e9 + 7
numbers_r_cumsum = numbers[N - 1:0:-1].cumsum()[::-1]
each = numbers[:N-1] * numbers_r_cumsum
total = 0
for e in each:
    total += e
    total %= mod
print(int(total))
n=int(input())	
s=0		
a=list(map(int,input().split()))
for i in range(n-1):
  for j in range(i+1,n):
    s+=a[j]*a[i]
print(s)
N = int(input())
As = list(map(int,input().split()))

out = (sum(As)**2 - sum([a**2 for a in As]))/2
print(out % (10**9+7))
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A, np.int64).cumsum()

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

print(ans)
import numpy as np
N=int(input())
A=list(map(int,input().split()))

mod=10**9+7

B=np.zeros(N+1)
for i in range(1,N+1):
    B[i]=A[i-1]+B[i-1]

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

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

sum = 0
for i in a:
    sum += i

sum = sum * sum % 1000000007

for j in a:
    sum = (sum - j*j) % 1000000007

print(int(sum/2))
#ここまでテンプレ
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

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

point = 0
mod = 10**9+7

su_a = sum(a)%mod

for i in a:
    point += (su_a-i)*i
    point %= mod

print(point//2)
n = int(input())
a = list(map(int,input().split()))
a2 = [i*i for i in a]
S = int((sum(a) * sum(a) - sum(a2))/2)
print(int(S % (1000000007)))
n = int(input())
a = [int(i) for i in input().split()]

res = sum(i for i in a)
ans = 0
base = 1e9 + 7
for i in a:
  res -= i
  ans += (i * res)
  
print(ans % base)
n = int(input())
a = list(map(int, input().split()))

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

y = (z % 1000000007)** 2

x = 0
for j in range(n):
    x += a[j] ** 2

p = ((y - x) / 2) % 1000000007
print(int(p))
import itertools
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    hoge = tuple(map(int, input().split()))
    sumn = 0
    for pair in list(itertools.combinations(hoge, 2)):
        sumn += (pair[0] * pair[1])
    print(sumn)

if __name__ == '__main__':
    main()
input_num = int(input())
input_list = list(map(int, input().split()))

sum = 0

for i in range(input_num):
    for j in range(input_num - i - 1):
        print(input_list[i], input_list[input_num -1-j])
        sum += input_list[i] * input_list[input_num -1 - j]

print(sum % 1000000007)
n = int(input())
a = list(map(int, input().split()))
s = 0
ans = 0
for i in range(len(a)):
  s += a[i]
for i in range(len(a)-1):
  s -= a[i]
  ans += s*a[i]
print(int(ans%1e9+7))
N = int(input())
A = list(map(int, input().split()))

MOD = 1000000007
ans = 0
powsum = 0
sumpow = 0
for i in range(N):
    powsum += A[i] 
    sumpow += (A[i]*A[i])

powsum = (powsum*powsum)
ans = (powsum-sumpow)/2.0
print(int(ans)%MOD)
from itertools import accumulate
mod= 1e9+7 
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans =0
    ac = list(accumulate(a))
 
    for i in range(n):
        ans += a[i]* (ac[-1]-ac[i])
        ans %=mod
    print(int(ans))
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [int(n) for n in int_list]

int_sum = sum(int_list) % target

sum_result = 0
for num in int_list:
    sum_result += num * ((int_sum - num) % target)
    if sum_result >= 10**9+7:
        sum_result = sum_result % target
print(int(sum_result/2))
N = int(input())
A = list(map(int, input().split()))


B = 0
C = 0
for i in range(N):
    B += A[i]
    C += A[i]**2

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

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

s = 0
for i in range(n):
  s += a[i]
  #sはaの和

t = 0
for i in range(n):
  t += a[i]**2
  #tはaの2乗和

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

ans = sum(a)**2

for i in range(n):
    ans -= a[i]**2

ans %= 10**9 + 7
print(ans//2)
p=10**9+7
n=int(input())
A=[int(x) for x in input().split()]
A2=[(x**2) for x in A]
print(int((((sum(A))**2-sum(A2))/2)%p))
N = int(input())
A = list(map(int, input().split()))

MOD = 1000000007
ans = 0
powsum = 0
sumpow = 0
for i in range(N):
    powsum += A[i] 
    sumpow += (A[i]*A[i])

powsum = (powsum*powsum)
ans = ((powsum-sumpow)/2)
print(int(ans)%MOD)