peterverebics/CodeNet_Python_118 huggingface dataset:
S = input()
T = input()

def matchcount(x, y):
    ret = 0
    for i in range(len(x)):
        if x[i] == y[i]: ret += 1
    return ret

rec = len(T)
for i in range(len(S)-len(T)):
    subst = S[i:i+len(T)]
    rec = min(rec, len(T) - matchcount(subst, T))

print(rec)
s = input()
t = input()

for i in range(len(t)):
    if t[:len(t)-i] in s:
        print(i)
        exit()

print(0)
import copy

s = input()
t = input()

sn = len(s)
tn = len(t)
answer = int(copy.deepcopy(tn))

for i in range(sn-tn+1):
    sk = s[i:i+tn]
    count = 0
    for j in range(tn):
        if sk[j] != t[j]:
            count += 1
    print(sk,count)
    if count < answer:
        answer = count

print(answer)
#B - Substring
S = input()
T = input()
ans = 10*9
for i in range(len(S)-len(T)):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
        else:
            pass
    if ans >= count:
        ans = count
    else:
        pass
print(ans)
s = input()
t = input()
minCount = 10000
i = 0
while i < len(s):
    countSame = 0
    j = 0
    while j < len(t) and i+j < len(s):
        if t[j] == s[i+j]:
            countSame += 1
        j += 1
        minCount = min(len(t) - countSame, minCount)
    i += 1
print(minCount)
s = input()
t = input()

maxsame = 0

for i in range(len(s)-len(t)):
  same = 0
  for j in range(len(t)):
    if s[i+j] == t[j]:
      same += 1
  if same > maxsame:
    maxsame = same
    
print(len(t)-maxsame)
S = input()
T = input()

max_count = 0
for start in range(len(T)):
    for end in range(start, len(T)):
        if T[start:end+1] in S[start:-(len(T)-end)]:

            max_count = max(max_count, len(T[start:end+1]))


answer = len(T) - max_count
print(answer)
S,T = input(),input()
r = len(T)

for i in range(len(S)-len(T)):
    t = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            t += 1
    r = min(r,t)

print(r)
s=input()
t=input()
mx=0
for i in range(len(s)-len(t)):
    sm=0
    for j in range(len(t)):
        if s[i+j]==t[j]:
            sm+=1
    mx=max(sm,mx)
print(len(t)-mx)
S = input()
T = input()

for r in range(len(T),0,-1):
    for i in range(len(T)-r+1):
        if T[i:i+r] in S[i:]:
            break
    else:
        continue
    print(len(T)-r)
    break
else:
    print(len(T))
S = input()
T = input()

result = 1000
for i in range(len(S) - len(T)):
    count = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            count += 1
    result = min(count, result)

print(result)
s = input()
t = input()
minr = len(t)
s_t_d = len(s) - len(t)
for i in range(s_t_d):
    cnt = 0
    for ss, ts in zip(s[i:i + len(t)], t):
        if ss != ts:
            cnt += 1
    minr = min(minr, cnt)
print(minr)
s = input()
t = input()
for i in range(1, len(t) + 1):
    if t[:i] in s:
        print(i)
        break
for j in t:
    if j in s:
        print(len(t) - 1)
        break
#!/usr/bin/env python3

import sys


INF = sys.maxsize // 10


def minimize(s, t):
    ns = len(s)
    nt = len(t)
    res = INF
    for start_idx in range(ns - nt):
        cand = sum(c != d for c, d in zip(s[start_idx: start_idx + nt], t))
        res = min(res, cand)
    return res


def main():
    s = input()
    t = input()
    print(minimize(s, t))


if __name__ == '__main__':
    main()
s = list(input())
t = list(input())

ans = 1000
sub = 0
for i in range(len(s)):
    if s[i] != t[sub]:
        sub = 0
        continue
    else:
        if sub == len(t) - 1:
            print(0)
            exit()
        sub += 1

for i in range(len(s) - len(t)):
    sub = 0
    an = 0
    for j in range(len(t)):
        if s[i + j] != t[sub]:
            an += 1
        sub += 1 
    ans = min(an, ans)

print(ans)
s = input()
t = input()

ans = float('infinity')

for i in range(len(s)-len(t)):
    c = len(t)
    for j in range(len(t)):
        if s[i+j] == t[j]:
            c -= 1
    ans = min(ans, c)

print(ans)
# t=int(input())
#
# for some_num in range(0,t):
#     n=int(input())


# s,t=[int(i) for i in input().split(" ")]
s=input()
t=input()
ls=len(s)
lt=len(t)

min_change=lt
print(min_change)

for i in range(0,ls-lt+1):
    if(s[i]==t[0]):
        d = 0
        for j in range(0,lt):
            if(s[i+j]!=t[j]):
                d+=1

        min_change=min(min_change,d)

print(min_change)
S = list(input())
T = list(input())
ans = 1001
for i in range(len(S)-len(T)):
  num = 0
  for j in range(len(T)):
    if S[j+i] != T[j]:
      num += 1
  if num <= ans:
    ans = num
print(ans)
S = input()
T = input()

minCount = len(T)
for i in range(len(S)-len(T)):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
    minCount = min(minCount, count)

print(minCount)
S=input("codefoces")
T=input("atcoder")
tlen = len(T)
 
 
for i in range(tlen, 1):
    for k in range(0, tlen+1-i):
        Tinclude = T[k:i]
        print(tlen-i)
        break
import sys

S = sys.stdin.readline().strip()
T = sys.stdin.readline().strip()

ls = len(S)
lt = len(T)
match = 0
for i in range(ls - lt):
    tmp = 0
    for j in range(lt):
        if S[i+j] == T[j]:
            tmp += 1
    match = max(match, tmp)

print(lt - match)
s = list(input())
t = list(input())

s_num = len(s)
t_num = len(t)

max_count = 0
for i in range(s_num - t_num + 1):
    count = 0
    for j in range(t_num):
        if s[i + j] == t[j]:
            count += 1
    if count > max_count:
        max_count = count

print(t_num - count)
S = input()
T = input()
ans = len(T)
for start in range(len(S) - len(T)):
  dif = 0
  for i in range(len(T)):
    if T[i] != S[start + i]:
      dif += 1
  ans = min(ans, dif) 
print(ans)
def resolve():
    s = input()
    t = input()
    ans = 0

    for i in range(len(t)):
        for j in range(i, len(t)):
            test = t[i:(j + 1)]
            if test in s[i:(len(s) - (len(t) - j) + 1)]:
                ans = max(ans, len(test))


    print(len(t) - ans)
resolve()
s = input()
t = input()
count = len(s)-len(t)
ans = 0
for i in range(count):
    res = 0
    for j in range(len(t)):
        if t[j] == s[i+j]:
            res += 1
    ans = max(ans, res)
print(len(t)-ans)
S = input()
T = input()
import math
if T in S:
    print(0)
    exit()
for i in range(1,math.ceil(len(T)/2)):
    if T[i:] in S or T[:-i] in S:
        print(i)
        exit()
        
print(len(T)-1)
#ceilevenoddformula
import math
import bisect
import copy
import time
from collections import Counter
from itertools import combinations
#map(int,input().split())
#int(x) for x in input().split()
s=input()
x=input()
if x in s:
	print(0)
else:
	ans=10**9
	for i in range(len(s)-len(x)):
		c=0
		for j in range(len(x)):
			if s[i+j]!=x[j]:
				c+=1
		ans=min(ans,c)
	print(ans)
s = input()
t = input()

t_len = len(t)
s_len = len(s)
max_ = 0
temp = 0

for i in range(s_len - t_len):
  for j in range(t_len):
    if s[i + j] == t[j]:
      temp += 1
  if max_ < temp:
    max_ = temp
  temp = 0
print(t_len - max_ + 1)
S = input()
T = input()

size = len(T)
n = len(S)
ans = size

for i in range(n-size+1):
    t = S[i:i+size]
    print(t)
    v = sum([k!=j for k, j in zip(T, t)])
    ans = min(v, ans)

print(ans)
S=input()
T=input()
A = []

for i in range(len(T)):           
    for j in range(i,len(T)):
        SS = S[i:j]
        if SS in T:
               A.append(j-i+1)
p = min(A)
print(p)
s=input()
a=len(s)
t=input()
b=len(t)
mincnt=b
for i in range(a-b):
	count=0
	for j in range(b):
		s1=s[i+j]
		s2=t[j]
		if(s1!=s2):
			count+=1
	if(mincnt>count):
		mincnt=count	
print(mincnt)
s = input()
t = input()
cnt = 0
ans = 0

for ti in range(len(t)):
    for si in range(ti,len(s)):
        if t[ti] == s[si]:
            if len(t) -ti < len(s) -si:
                cnt += 1
                ans = max(ans,cnt)
        else:
            cnt = 0
print(len(t) - ans)
# -*- coding: utf-8 -*-
S = str(input())
T = str(input())

len_S = len(S)
S_part_dict = {}
for i in range(len_S):
    for j in range(i, len_S):
        S_part_dict[S[i:j + 1]] = i

max_part_len = 0
for part_str, len_from_top in S_part_dict.items():
    now_len_part = len(part_str)
    if now_len_part <= max_part_len:
        continue
    if T[len_from_top:-(len_S - now_len_part)].count(part_str):
        max_part = now_len_part

print(len(T) - now_len_part)
list_data = [input() for _ in range(2)]
print(list_data)

s = list_data[0]
t = list_data[1]

len_t = len(t)

max_correct = 0
for i in range(len(s)-len(t)):
  correct = 0
  for j in range(len(t)):
    if s[i+j] == t[j]:
      correct += 1
  
  if max_correct < correct:
    max_correct = correct

print(len_t - max_correct)
s = input()
t = input()
ans = 10**4
for i in range(len(s)-len(t)):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            cnt += 1
    ans = min(cnt,ans)
print(ans)
from collections import deque
import sys, copy, itertools,heapq
input = sys.stdin.readline
 
S = input()
T = input()
s = len(S)
t = len(T)
#A=[0]*(len(S))

ans = t
for i in range(len(S)-len(T)+1):
  x = 0
  for j in range(len(T)):
    if S[i+j] != T[j]:
      x += 1
  ans = min(ans, x)

#print(s)
#print(t)
#print(A)
print(ans)
s = input()
t = input()
m = len(t)
ans = m 
n = len(s)
for i in range(n-m):
    tmp = 0
    for j in range(m):
        if s[i+j] != t[j]:
            tmp += 1
    ans = min(ans, tmp)
print(ans)
S = str(input())
T = str(input())
tempcount = 0
mincount = 0

if S in T:
    print("0")
    exit

for i in range(len(S) - len(T)+1):
    for j in range(len(T)):
        if S[i + j] != T[j]:
            tempcount += 1
    if i == 0:
        mincount = tempcount
    elif tempcount < mincount:
        mincount = tempcount
    tempcount = 0
    
print(mincount)
s=input()
t=input()

result = 0
for i in range(len(s)):
  count = 0
  for j in range(len(t)):
    if i+j > len(s)-1:
      break
    if t[j] == s[i+j]:
      count += 1
      
  result = max(result,count)
print(len(t)-result)
s = input()
t = input()

t_len = len(t)
s_len = len(s)
max_ = 0
temp = 0

for i in range(s_len - t_len):
  for j in range(t_len):
    if s[i + j] == t[j]:
      temp += 1
  if max_ < temp:
    max_ = temp
  temp = 0
print(t_len - max_)
S = input()
T = input()
ans = 0
for i in range(len(S)-len(T)+1):
    cnt = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            cnt += 1
        else:
            cnt = 0
        if cnt > ans:
            ans = cnt
print(len(T)-ans)
s = input()
t = input()
slen = len(s)
tlen = len(t)
ans = tlen
temp = 0

for start in range(0,slen-tlen):
    for i in range(0,tlen):
        if t[i] != s[start+i]:
            temp += 1
    ans = min(ans,temp)
    temp = 0

print(ans)
input_list = [input() for i in range(2)]
M = len(input_list[0])
N = len(input_list[1])


ans = 0

for i in range(M-N+1):

    num = 0

    substring = input_list[0][i:i+N]

    for j in range(len(substring)):

        if substring[j] != input_list[1][j]:

            num += 1

    ans = num

print(ans)
import numpy as np
import sys

S = input()
T = input()

counter = 0
max_counter = 0

for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        if S[j+i] == T[j]:
            counter = counter + 1
    if counter > max_counter:
        max_counter = counter
        counter = 0

print(int(len(T)) - int(max_counter))
S=input()
T=input()
ans=len(T)


for j in range(len(S)-len(T)+1):
    total=0
    for i in range(len(T)):
        if S[i+j-1]!=T[i]:
            total+=1
    if ans>=total:
        ans=total
        
print(ans)
import re
import sys
s = input()
t = input()
for i in range(len(t)):
  if  re.search(t,s) != None:
    print(0)
    sys.exit()
  t1 = t[1:]
  t2 = t[:len(t)-i]
  if None!=re.search( ".+"+t1+".+",s):
    print(i)
    sys.exit()
  if None!=re.search( ".+" + t2 + ".+",s):
    print(i)
    sys.exit()
    
  if i == len(t)-1:
    print(len(t)-1)
#!/usr/bin/env python3
import sys
def input(): return sys.stdin.readline().rstrip()

def hantei(S,T):
    anss=0
    for i in range(len(S)):
        if S[i]!=T[i]:
            anss+=1
    return anss

def main():
    S=input()
    T=input()
    ans=10000
    for i in range(len(S)-len(T)):
        ans=min(ans,hantei(T,S[i:i+len(T)]))
    print(ans)



if __name__ == '__main__':
    main()
s = input()
t = input()

m = 0
l = len(t)
# print(l)
ans = 100000000
for tt in range(0,l):
    for pp in range(l , tt, -1):
        # print(t[tt:pp])
        if t[tt:pp] in s[tt:len(s)-(l-pp)]:
            # print("ok ", tt + (l-pp))
            if ans > tt + (l-pp):
                ans = tt + (l-pp)


print(ans)
S = input()
T = input()
s = len(S)
t = len(T)
A=[0]*(len(S))
 
ans = t
for i in range(len(S)-len(T)):
  for j in range(len(T)):
    if S[i+j] != T[j]:
      A[i] += 1
  ans = min(ans, A[i])
 
#print(s)
#print(t)
#print(ANS)
print(ans)
s=list(input())
t=list(input())
ans=len(t)
for i in range(len(s)-len(t)):
    tmp=0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            tmp+=1
    ans=min(ans,tmp)

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

m=sum(i)

ans=0
for k in range(n):
    ans+=(i[k]*(m-i[k]))
ans=ans//2
ans=ans%(10**9+7)
print(ans)
N = int(input())
A_List = [int(i) for i in input().split()]

Y = 0
M = 10**9+7
tempSum = sum(A_List)

for x in A_List:
    tempSum -= x
    Y += x * tempSum
    Y = Y%M
print(Y)
#!/usr/bin/env python3


def solve(N, A):
    MOD = 10**9 + 7
    total = sum(A)
    ans = 0

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

    return ans


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

    ans = solve(N, A)

    print(ans)


if __name__ == "__main__":
    main()
#coding: utf-8

MOD = 1000000000 + 7

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

ret = 0
for a in A:
    s -= a
    ret += a * s
    ret %= MOD

print(ret)
n = int(input())
A = map(int,input().split())

mod = 1000000007

ans = 0
tmp1, tmp2 = 0, 0

for m in A:
  tmp1 = (tmp1+m) %mod
  tmp2 = (tmp2+m*m%mod)%mod
  
ans = ((tmp1*tmp1)%mod-tmp2)%mod

if ans%2 ==0:
  ans = ans/2
else:
  ans =(ans+mod)/2

print(int(ans))
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

M = 10**9+7
n = inp()
x = ip()

sm = sum(x)
sq = sm*sm
ans = 0
for i in x: ans += i*i
ans = (sq-ans)//2
print(ans%M)
N = int(input())
A = list(map(int,input().split()))
K = sum(A)
S = 0

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

ans = S%(10**9+7)

print(ans)
n = input()
a = [int(num) for num in input().split(" ")]

mod_value = 10**9 + 7

sum = 0
total = 0
for i in reversed(range(1, len(a))):
    sum += a[i]
    total += a[i-1] * sum

print(total%mod_value)
import functools
import operator

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

s=sum(a)

for i in range(1,len(a)+1):
    ans += a[i-1] * (s-a[i-1])
    s = s-a[i-1]
    ans = ans % (10 ** 9 + 7)

print(ans)
MOD = 10**9+7

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

A_sum = sum(A)

r = 0
for i, a in enumerate(A):
    x = A[i]*(A_sum - a)
    r = (r+x) % MOD

# print(r)

r = (r * pow(2, MOD-2, MOD)) % MOD

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

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

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

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

MOD = 10**9 + 7
sums = [A[0]]
for a in A[1:]:
    sums.append((a + sums[-1]) % MOD )

alls = 0
for i in range(1, len(A)):
    # print(A[i], sums[i-1])
    alls += A[i] * sums[i-1]
    alls %= MOD
print(alls)
N = int(input())
list_a = [int(x) for x in input().split(' ')]

# sum_a = sum(list_a) % (10**9+7)
# sum_a2 = sum([(x**2) % (10**9+7) for x in list_a])
sum_a = sum(list_a)
sum_a2 = sum([x**2 for x in list_a])

print(((sum_a ** 2 - sum_a2) // 2) % (10**9+7))
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))%(10**9+7)
print(ans%(10**9+7))
from sys import stdin
from itertools import accumulate
input = stdin.readline

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

_sum=sum(A[1:])
mod=10**9+7
re=0
for i in range(0,N-1):
    re+=A[i]*_sum
    _sum-=A[i+1]
    re%=mod
    _sum%=mod
print(re%mod)
N=int(input())
A=list(map(int, input().split()))
MOD=10**9+7
tmp1 = 0
tmp2 = 0
for a in A:
    tmp1 += a
    tmp2 += (a**2)

ans = (tmp1**2 - tmp2)//2
print(ans%MOD)
N = int(input())
A = list(map(int, input().split()))
c=0
d=sum(A)
for i in range(0,N-1):
    d-=A[i]
    c+=A[i]*d
    if(c>10**9+7):
        c%=(10**9+7)
print(c)
n = int(input())
A = list(map(int, input().split()))
M = 10**9 + 7

S = sum(A)
S2 = sum(map(lambda x: x**2, A))
print(((S**2 - S2)// 2)%M)
import sys

MOD = 10**9 + 7

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

sumA = 0
for A in As:
    sumA += A
    sumA %= MOD
#print('# sumA:', sumA, file=sys.stderr)

ans = sumA * sumA % MOD
for A in As:
    ans -= A * A % MOD
    ans %= MOD
#print('# ans:', ans, file=sys.stderr)

inv2 = pow(2, MOD-2, MOD)
ans *= inv2
ans %= MOD

print(ans)
m=10**9+7
n=int(input())
a=[int(i) for i in input().split()]
ans=0 ; s=a[-1]
for i in range(n-2,-1,-1):
    ans=(ans+s*a[i])%m
    s=(s+a[i])%m
print(ans%m)
N = int(input())
A = [int(i) for i in input().split()]
B = [0]*N
res = 0
B[N-1] = A[N-1]
for i in range(1, N):
    B[N-i-1] = B[N-i] + A[N-i-1]
for i in range(N-1):
    res = (res + A[i] * B[i+1]) % (10**9+7)
print(res)
def main():
	n = int(input())
	h = list(map(int,input().split()))

	sum_h = sum(h)%(10**9 + 7)
	ans = 0
	for i in h:
		i = i%(10**9 + 7)
		sum_h -= i
		ans += i*sum_h

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

	

if __name__ == '__main__':
	main()
from itertools import accumulate
def main():
    n=int(input())
    a=list(map(int,input().split()))
    aa=list(accumulate(a))
    mod=10**9+7
    ans=0
    for i in range(n):
        ans += a[i]*(aa[-1]-aa[i])%mod
    print(ans%mod)
    
if __name__ == "__main__":
    main()
#!/usr/bin/env python3

import functools


M = 10 ** 9 + 7


def sum_mod(xs):
    return functools.reduce(lambda x, y: (x + y) % M, xs) % M


def compute(bs):
    term1 = sum_mod(bs) * sum_mod(bs) % M
    term2 = sum_mod(b * b for b in bs)
    double_res = (term1 - term2) % M
    inv2 = pow(2, M - 2, M)
    res = double_res * inv2 % M
    return res


def main():
    n = int(input())
    bs = [int(b) for b in input().split()]
    res = compute(bs)
    print(res)


if __name__ == '__main__':
    main()
N = int(input())
A = list(map(int,input().split()))
ans = 0
num = sum(A)
for i in range(N - 1):
  num -= A[i]
  ans += A[i] * num
print(ans % (10 ** 9 + 7))
N = int(input()); MOD = pow(10,9)+7
A = list(map(int,input().split()))
S = sum(A)**2%MOD
nijo = 0
for x in A:
  nijo = (nijo + x**2)%MOD
ans = (S-nijo)*pow(2,MOD-2,MOD)%MOD
print(ans%MOD)
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])
print(ans//2%(10**9+7))
import math

n = int(input())
aL = list(map(int, input().split(" ")))

MOD = 10**9 + 7

aL2 = [aL[-1]]
for a in reversed(aL[:-1]):
    aL2.append((aL2[-1] + a) % MOD)
aL2 = list(reversed(aL2))

ans = 0
for i in range(n - 1):
    ans += aL[i] * aL2[i + 1]
    ans %= MOD

print(ans)
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())
A = list(map(int, input().split()))
mod =10**9 +7
sum_a =sum(A)
ans =0
for i in range(N-1):
    sum_a -=A[i]
    ans +=(A[i] *(sum_a)) %mod
ans %=mod        
print(ans)
N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = pow(10,9)+7

B = []
x = 0
for i in range(N-1):
    x += A[i]
    x %= mod
    B.append(x)

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

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

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

    ans = 0
    mod = (10 ** 9) + 7
    csum = sum(a)

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

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

S = 0
ans = 0
for a in A:
    ans = (ans + a * S) % MOD
    S += a
print(ans)
n=int(input())
a=[int(x) for x in input().split()]

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

c=0
for j in range(n-1):
  c+=a[j]*(b[n-1]-b[j])
  
print(c%(10**9+7))
n,*a=map(int,open(0).read().split())

b=sum(map(lambda x:x*x,a))
mod=10**9+7
ans=(sum(a)**2-b)//2

print(ans%mod)
def main():
    n = int(input())
    a = [int(v) for v in input().split()]
    m = 1000000007
    ans = 0
    ss = sum(a[1:])
    for i in range(n-1):
        ans += a[i]*ss
        ss -= a[i+1]
        ans %= m
    print(ans)

main()
from itertools import accumulate

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

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

def pw(b, ex):
    if ex == 0: return 1
    if ex == 1: return b
    if ex & 1: return b % mod * pw((b*b) % mod, ex >> 1) % mod
    return pw((b*b) % mod, ex >> 1) % mod

n = int(input())
x = list(map(int,input().split()))
st = 0
en = 0

for i in x:
    st = (st + i) % mod
    en = (en + (i * i) % mod) % mod
    
st *= st
ans = int((st - en + mod) % mod)
ans = int(ans * int(pw(2, mod - 2)) % mod) % mod
print (int(ans))
def li():
    return [int(x) for x in input().split()]

N = int(input())
A = li()
d = 10**9 + 7
B = [A[i] % d for i in range(len(A))]

s = 0
s2 = 0
for i in range(len(B)):
    s += B[i]
    s = s
    s2 += B[i] ** 2
    s2 = s2

ans = ((s**2 - s2) // 2) % d

print(ans)
n=int(input())
*a,=map(int,input().split())
b=[x**2 for x in a]

mod=10**9+7
print(((sum(a)**2-sum(b))//2)%mod)
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    x = 0
    ans = 0

    for i in range(1, n):
        x = (x + a_list[i - 1]) % mod
        ans = (ans + a_list[i] * x) % mod

    print(ans)


if __name__ == "__main__":
    main()
#!/usr/bin/env python3
N = int(input())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7

s = sum(A)** 2

a = 0
for i in A:
    a += (i ** 2)

ans = (s - a) // 2
ans = ans % mod

print(ans)
n=int(input())
a=list(map(int,input().split()))
mod=1000000007
sum_a=sum(a)

ans=0
for i in range(n):
    temp=(sum_a-a[i])*a[i]

    ans+=temp
print((ans//2)%mod)
#!/usr/bin/env python3
def main():
    _ = int(input())
    A = [int(x) for x in input().split()]
    mod = 10 ** 9 + 7

    lst = [sum(A)]
    for j in A:
        lst.append(lst[-1] - j)
    ans = 0
    for index, i in enumerate(A):
        ans += i * lst[index + 1] % mod
    print(ans % mod)


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

mod=10**9+7

sumA=sum(A)

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

ans=ans//2
print(ans%mod)