Harryxun/stf_run huggingface dataset:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from math import sqrt
from collections import Counter, deque
N = int(input())
As = list(mapint())
As.sort()
C = Counter(As)

MAX = As[-1]
Ps = deque(As)
cnt = 0
for _ in range(N):
    p = Ps.popleft()
    if C[p]>=2:
        continue
    Ps = deque([i for i in Ps if i%p!=0])
    cnt += 1
    if p>=sqrt(MAX):
        break
print(len(Ps)+cnt)

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from math import sqrt
from collections import Counter, deque
N = int(input())
As = list(mapint())
As.sort()
C = Counter(As)
S = set()

MAX = As[-1]
cnt = 0
for n in range(N):
    p = As[n]
    if p in S:
        continue
    i = 1
    while MAX>=p*i:
        S.add(p*i)
        i += 1
    if C[p]>=2:
        continue
    cnt += 1

print(cnt)
x = int(input())
if x == 0: pritn(1)
else: print(0)

### FIXED CODE ###

x = int(input())

if x == 0: print(1)
else: print(0)
from fracrions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
d = [int(i) for i in input().split()]
 
print(lcm(d[0],d[1]))



### FIXED CODE ###

from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
d = [int(i) for i in input().split()]
 
print(lcm(d[0],d[1]))
s=str(input())
k=int(input())
a=len(s)

if k<a
print(s)

elif k>a
print(k+"...")

### FIXED CODE ###


k= int(input())
s= input()

a=len(s)

if k >= a:
  print(s)

else :
  print(s[:k]+"...")
A,B = input().split()
B2 = float(B)*100
print(int(A*B2))

### FIXED CODE ###

import math

A,B = input().split()
C = int(A)*int(float(B)*1000)
print(math.floor(C//1000))
i = list(map(int, input().split()))
print(i[2] - (i[0] - i[1]))
i = list(map(int, input().split()))
n = i[2] - (i[0] - i[1])
if n > 0:
    print(n)
else:
    print(0)


### FIXED CODE ###

i = list(map(int, input().split()))
n = i[2] - (i[0] - i[1])
if n > 0:
    print(n)
else:
    print(0)
import sys
import math

sys.setrecursionlimit(100000000)

n = int(input())
s = int(input())

def f(b, n):
    if n<b:
        return n
    else:
        return f(b, n//b) + n%b

if s > n:
    print(-1)
else:
    for b in range(2, math.ceil(math.sqrt(n))+1):
        if f(b, n)==s:
            print(b)
            break
    else:
        if f(n+1-s, n)==s:
            print(n+1-s)
        else:
            print(-1)

### FIXED CODE ###

import sys
import math

sys.setrecursionlimit(100000000)

n = int(input())
s = int(input())

def f(b, n):
    if n<b:
        return n
    else:
        return f(b, n//b) + n%b

if s > n:
    print(-1)
elif s==n:
    print(s+1)
else:
    for b in range(2, math.ceil(math.sqrt(n))+1):
        if f(b, n)==s:
            print(b)
            break
    else:
        for d in range(math.floor(math.sqrt(n)), 0, -1):
            if (n-s)%d==0 and f((n-s)//d+1, n)==s:
                print((n-s)//d+1)
                break
        else:
            print(-1)
N = int(input())
A = []
B = []
for i in range(N):
  a,b = map(input().split())
  A.append(a)
  B.append(b)

A = sorted(A)
B = sorted(B)
 
if N%2==1:
  print(B[N//2] - A[N//2] + 1)
else:
  print( (B[N//2-1]+B[N//2]) - (A[N//2-1]+A[N//2]) + 1 )

### FIXED CODE ###

N = int(input())
A = []
B = []
for i in range(N):
  a,b = map(int, input().split())
  A.append(a)
  B.append(b)

A = sorted(A)
B = sorted(B)
 
if N%2==1:
  print(B[N//2] - A[N//2] + 1)
else:
  print( (B[N//2-1]+B[N//2]) - (A[N//2-1]+A[N//2]) + 1 )
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

pre = [[] for i in range(k)]

for i in range(n):
    #print(i, pre[i%k], t[i])
    pre[i%k].append(t[i])
#print(pre)

def score(h):
    c_r = 0
    c_s = 0
    c_p = 0
    num = "".join(h)
    count = 1
    result = ''

    # 配列全体のループ
    for i in range(len(num)):
        try:
            if num[i] == num[i+1]:
                count = count + 1
            else:
                result = result + str(num[i]) + str(count)
                count = 1
        except:
            # 最後の文字セットがOutOfRangeになるので結果に出力
            result = result + str(num[i]) + str(count)
    
    for i in range(len(result)//2):
        ko = result[2*i]
        wa = int(result[(2*i)+1])
        if wa%2 == 0:
            if ko == "r":
                c_r += wa//2
            elif ko == "s":
                c_s += wa//2
            else:
                c_p += wa//2
        else:
            if ko == "r":
                c_r += 1 + (wa-1)//2
            elif ko == "s":
                c_s += 1 + (wa-1)//2
            else:
                c_p += 1 + (wa-1)//2


    return c_r * p + c_s * r + c_p * s

ans = 0
for i in range(len(pre)):
    ans += score(pre[i])
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

pre = [[] for i in range(k)]

for i in range(n):
    #print(i, pre[i%k], t[i])
    pre[i%k].append(t[i])
#print(pre)

def score(h):
    c_r = 0
    c_s = 0
    c_p = 0
    num = "".join(h)
    count = 1
    result = ''

    # 配列全体のループ
    for i in range(len(num)):
        try:
            if num[i] == num[i+1]:
                count = count + 1
            else:
                result = result + str(num[i]) + str(count)
                ko = num[i]
                wa = count 
                if wa%2 == 0:
                    if ko == "r":
                        c_r += wa//2
                    elif ko == "s":
                        c_s += wa//2
                    else:
                        c_p += wa//2
                else:
                    if ko == "r":
                        c_r += 1 + (wa-1)//2
                    elif ko == "s":
                        c_s += 1 + (wa-1)//2
                    else:
                        c_p += 1 + (wa-1)//2
                count = 1
        except:
            # 最後の文字セットがOutOfRangeになるので結果に出力
            result = result + str(num[i]) + str(count)
            ko = num[i]
            wa = count 
            if wa%2 == 0:
                if ko == "r":
                    c_r += wa//2
                elif ko == "s":
                    c_s += wa//2
                else:
                    c_p += wa//2
            else:
                if ko == "r":
                    c_r += 1 + (wa-1)//2
                elif ko == "s":
                    c_s += 1 + (wa-1)//2
                else:
                    c_p += 1 + (wa-1)//2

    #print(result,c_r * p + c_s * r + c_p * s )
    return c_r * p + c_s * r + c_p * s

ans = 0
for i in range(len(pre)):
    ans += score(pre[i])
print(ans)
count = 0

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    R = A[mid:right]
    # print('merge for', left, 'to', right)
    L.append(1000000)
    R.append(1000000)
    
    # print('n1', n1)
    # print('n2', n2)
    # print('L', L)
    # print('R', R)

    i = 0
    j = 0
    C = []
    global count
    
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    # print(A)


def merge_sort(A, left, right):

    # print(left, right)
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)


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

merge_sort(A, 0, len(A))

# print('==========')

print(' '.join(list(map(str, A))))
print(count)



### FIXED CODE ###

def merge(A, left, mid, right):
    global count
    inf = 10 ** 9
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]

    i = 0
    j = 0
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

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

print(' '.join(list(map(str, A))))
print(count)
N = int(input())
A = list(map(int, input().split()))

import numpy as np

A = sorted(A)
B = np.cumsum(A)

mem = N
for i in range(N-1):
    if 2*B[i] >= A[i+1]:
        mem = min(i, mem)
    else:
        mem = N
print(N-mem)

### FIXED CODE ###

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

import numpy as np

A = sorted(A)
B = np.cumsum(A)

mem = N
for i in range(N-1):
    if 2*B[i] >= A[i+1]:
        mem = min(i, mem)
    else:
        mem = N
print(N-mem)
def comb(n,r):
    return (((fact_list[n]*inv(fact_list[n-r]))%998244353)*inv(fact_list[r]))%998244353
def inv(n):
    s=1
    for i in range(30):
        if i!=23 and i!=26:
            s=(s*n)%998244353
        n=(n**2)%998244353
    return s

fact_list=[1 for i in range(300001)]
for i in range(1,300001):
    fact_list[i]=(fact_list[i-1]*i)%998244353

s=input().split()
n,a,b,k=int(s[0]),int(s[1]),int(s[2]),int(s[3])
res=0
for i in range(n):
    if (k-a*i)%b==0 and (k-a*i)//b<=n:
        res+=comb(n,i)*comb(n,(k-a*i)//b)
        res%=998244353
print(res)

### FIXED CODE ###

fact_list=[None]*300001
inv_fact_list=[None]*300001
fact_list[0]=1
inv_fact_list[0]=1
"""
def inv(n):
    if inv_fact_list[n]!=None:
        return inv_fact_list[n]
    m=fact_list[n]
    s=1
    for i in range(30):
        if i!=23 and i!=26:
            s=(s*m)%998244353
        m=(m**2)%998244353
    inv_fact_list[n]=s
    return s
def enc(n):
    if n==0:
        return "("
    s=""
    while n>0:
        s+=chr(n%86+40)
        n//=86
    return s
 
def dec(s):
    n=0
    for i in range(len(s)):
        n+=(86**i)*(ord(s[i])-40)
    return n
"""
def comb(n,r):
    if r==0 or r==n:
        return 1
    if r==1 or r==n-1:
        return n
    if inv_fact_list[n-r]!=None:
        invnr=inv_fact_list[n-r]
    else:
        m=fact_list[n-r]
        invnr=1
        for i in range(30):
            if i!=23 and i!=26:
                invnr=(invnr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[n-r]=invnr
    if inv_fact_list[r]!=None:
        invr=inv_fact_list[r]
    else:
        m=fact_list[r]
        invr=1
        for i in range(30):
            if i!=23 and i!=26:
                invr=(invr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[r]=invr
    return (((fact_list[n]*invnr)%998244353)*invr)%998244353
 
for i in range(1,300001):
    fact_list[i]=(fact_list[i-1]*i)%998244353
 
s=input().split()
n,a,b,k=int(s[0]),int(s[1]),int(s[2]),int(s[3])
res=0
for i in range(n+1):
    if k-a*i<0:
        break
    if (k-a*i)%b==0 and 0<=(k-a*i)//b<=n:
        res=(res+comb(n,i)*comb(n,(k-a*i)//b))%998244353
print(res)
import sys

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

X,Y = (int(x) for x in input().split())

if (X+Y) % 3 != 0:
  print(0)
  sys.exit()
  
n = (2*Y-X) / 3 if (2*Y-X) % 3 == 0 else -1
m = (2*X-Y) / 3 if (2*X-Y) % 3 == 0 else -1
if n < 0 or m < 0:
  print(0)
  sys.exit()
print(int(cmb(n+m,n)))

### FIXED CODE ###

import sys

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

X,Y = (int(x) for x in input().split())

if (X+Y) % 3 != 0:
  print(0)
  sys.exit()

if (2*Y-X) % 3 == 0:
  n = (2*Y-X) // 3  
else:
  n = -1

if (2*X-Y) % 3 == 0:
  m = (2*X-Y) // 3
else:
  m = -1

if n < 0 or m < 0:
  print(0)
  sys.exit()
print(int(cmb(n+m,n)) % (10**9 +7))
a,b,k = map(int,input().split())
for i in range(n):
  b += a//2
  a = a//2
  a += b//2
  b = b//2
print(a,b)

### FIXED CODE ###

a,b,k = map(int,input().split())
cnt = 0
while cnt < k:
  b += a//2
  a = a//2
  cnt += 1
  if cnt < k:
    a += b//2
    b = b//2
    cnt += 1
print(a,b)
T,X=map(int,input().split())
return T/X

### FIXED CODE ###

T,X=map(int,input().split())
print(T/X)
import math
n = int(input())
split = math.floor(n ** (1/2))
ans = 0
for i in range(1, split):
    m = n / (split - i)
    if m.is_integer():
        ans = m
        break
print((int(m) - 1) + (int(n / m) - 1))

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
divisors = []
def make_divisors(n):
    for i in range(1, int(math.sqrt(n)) + 1):
        a, b = 0, 0
        if n % i == 0:
            a = i
            b = n // i
            divisors.append([a, b])

make_divisors(N)

ans = float('inf')
for i in divisors:
    a, b = i
    ans = min(ans, a + b - 2)
print(ans)
#!/usr/bin/env python3
import sys
import math

n = int(input())
# 長さN になるまで、%5 = 1となる整数を列挙する
def sleve_of_Eratosthenes(n):
    # N 以下の素数を全列挙
    res = []
    if n == 1:
        return res
    ok = [False] * n
    for i in range(2, n + 1):
        if ok[i]:
            continue
        tmp = 1
        res.append(i)
        while tmp * i <= n:
            ok[tmp * i] = True
            tmp += 1
    return res


prime = sleve_of_Eratosthenes(55555)
len_arr = 0
arr = []
for a in prime:
    if a % 5 == 1:
        arr.append(a)
        len_arr += 1
        if len_arr == n:
            break
print(*arr)


### FIXED CODE ###

#!/usr/bin/env python3
n = int(input())
# 長さN になるまで、%5 = 1となる整数を列挙する
def sleve_of_Eratosthenes(n):
    # N 以下の素数を全列挙
    res = []
    if n == 1:
        return res
    ok = [False] * (1 + n)
    for i in range(2, n + 1):
        if ok[i]:
            continue
        tmp = 1
        res.append(i)
        while tmp * i <= n:
            ok[tmp * i] = True
            tmp += 1
    return res


prime = sleve_of_Eratosthenes(55555)
len_arr = 0
arr = []
for a in prime:
    if a % 5 == 1:
        arr.append(a)
        len_arr += 1
        if len_arr == n:
            break
print(*arr)
b=int(input())
if b=A:
  print(T)
if b=T:
  print(A)
if b=C: 
  print(G)
if b=G  
  print(C)

### FIXED CODE ###

b=input()
 
if b=='A':
    print('T')
elif b=='T':
    print('A')
elif b=='G':
    print('C')
else:
    print('G')
def main():
    N, K = list(map(int, input().split()))
    P = list(map(int, input().split()))
    C = list(map(int, input().split()))

    max_score = max(C)
    score = C
    P_now = P
    P_ci = P
    for _ in range(K-1):
        score = [score[i]+C[num-1] for i, num in enumerate(P_now)]
        if max_score < max(score):
            max_score = max(score)
            P_ci = P_now
        P_now = [P[i-1] for i in P_now]
        if P_ci == P_now:
            break
    print(max_score)

if __name__ == "__main__":
    main()

### FIXED CODE ###

S = input()
a = 0
for i in range(3):
  if S[i]=="R":
    a+=1
  if S[i]=="S" and a>0:
      break
print(a)
n, k = map(int, input().split())
A = list(map(int, input().split()))
doubleA = {}
doubleA[1] = [A[i-1] for i in range(n)]

def f(x):
    return A[x-1]
for i in range(2, 73):
    doubleA[i] = [doubleA[i-1][doubleA[i-1][j]-1] for j in range(n)]
c = k - 2**(len(bin(k))-3)
start = doubleA[2**(len(bin(k))-3)][0]
for i in range(c):
    start = f(start)
print(start)

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
now = 1
 
for i in range(len(bin(k))-2):
    if (k>>i)&1:
        now = A[now-1]
    A = [A[a-1] for a in A]
print(now)
N, R = map(int, input())
if N >= 10:
  print(R)
else:
  print(R - 100 * (10 - N))

### FIXED CODE ###

N, R = map(int, input().split())
if N >= 10:
  print(R)
else:
  print(R + 100 * (10 - N))
a,b,x=map(int, input().split())
print("YES" if a+b>=x and a=<x else "NO")

### FIXED CODE ###

a,b,x=map(int, input().split())
print("YES" if a+b>=x and a<=x else "NO")
N, W = map(int, input().split())
goods = []
for _ in range(N):
    goods.append(list(map(int, input().split())))

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(goods[i][0], W + 1):
        if j - goods[i - 1][0] >= 0:
            dp[i][j] = max(dp[i - 1][j - 1], dp[i - 1][j - goods[i - 1][0]] + goods[i - 1][1])
        else:
            dp[i][j] = dp[i - 1][j]
# print(dp)
print(dp[-1][-1])


### FIXED CODE ###

import numpy as np

N, weights = map(int, input().split())

# dp = [0] * (weights + 1)
dp = np.zeros(weights + 1, dtype=np.int64)

while N:
    w, v = map(int, input().split())
    np.maximum(dp[:-w] + v, dp[w:], out=dp[w:])
    # for i in range(weights, -1, -1):
    #     if i - w >= 0:
    #         dp[i] = max(dp[i], dp[i - w] + v)
    # print(dp)
    N -= 1
print(dp[-1])
I = list(map(int,input().split()))
N = I[0]
K = I[1]
Q = I[2]
A = [0] * Q
for i in range(Q):
    A[i] = int(input())
count = [0] * N
for i in range(Q):
    count[A[i]] += 1
for i in range(N):
    ans = K - Q + count[i]
    if ans > 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

I = list(map(int,input().split()))
N = I[0]
K = I[1]
Q = I[2]
A = [0] * Q
for i in range(Q):
    A[i] = int(input())
C = [0] * N
for i in range(Q):
    C[A[i]-1] += 1
for i in range(N):
    ans = K - Q + C[i]
    if ans > 0:
        print('Yes')
    else:
        print('No')
import collections
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]

dis = [[-1]*W for i in range(H)]
black = set()
white = set()

start = [-1, -1]

for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            start[0] = i
            start[1] = j

            break
    if start[0] != -1:
        break


dp = [[10**9]*W for i in range(H)]


q = collections.deque([start])
dp[start[0]][start[1]] = 0
count = 0
while(q):
    x, y = q.popleft()
    if x > 0:
        if dp[x-1][y] > dp[x][y]+1:
            if A[x-1][y] == ".":
                dp[x-1][y] = dp[x][y]+1
            else:
                dp[x-1][y] = 0
            q.append([x-1, y])
    if x < W-1:
        if dp[x+1][y] > dp[x][y]+1:
            if A[x+1][y] == ".":
                dp[x+1][y] = dp[x][y]+1
            else:
                dp[x+1][y] = 0
            q.append([x+1, y])
    if y > 0:
        if dp[x][y-1] > dp[x][y]+1:
            if A[x][y-1] == ".":
                dp[x][y-1] = dp[x][y]+1
            else:
                dp[x][y-1] = 0
            q.append([x, y-1])
    if y < H-1:
        if dp[x][y+1] > dp[x][y]+1:
            if A[x][y+1] == ".":
                dp[x][y+1] = dp[x][y]+1
            else:
                dp[x][y+1] = 0
            q.append([x, y+1])
ans = 0
for i in range(H):
    ans = max(ans, max(dp[i]))
print(ans)


### FIXED CODE ###

import collections
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]
dp = [[H+W]*W for i in range(H)]

q = collections.deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            dp[i][j] = 0
            q.append([i, j])
            break
    if q:
        break


while(q):
    x, y = q.popleft()
    if x > 0:
        if dp[x-1][y] > dp[x][y]+1:
            if A[x-1][y] == ".":
                dp[x-1][y] = dp[x][y]+1
            else:
                dp[x-1][y] = 0
            q.append([x-1, y])
    if x < H-1:
        if dp[x+1][y] > dp[x][y]+1:
            if A[x+1][y] == ".":
                dp[x+1][y] = dp[x][y]+1
            else:
                dp[x+1][y] = 0
            q.append([x+1, y])
    if y > 0:
        if dp[x][y-1] > dp[x][y]+1:
            if A[x][y-1] == ".":
                dp[x][y-1] = dp[x][y]+1
            else:
                dp[x][y-1] = 0
            q.append([x, y-1])
    if y < W-1:
        if dp[x][y+1] > dp[x][y]+1:
            if A[x][y+1] == ".":
                dp[x][y+1] = dp[x][y]+1
            else:
                dp[x][y+1] = 0
            q.append([x, y+1])
ans = 0
for i in range(H):
    ans = max(ans, max(dp[i]))
print(ans)
def resolve():
    n = int(input())
    x_list = list(map(int, input().split()))
    mn =　10**6
    for i in range(1, max(x_list)+1):
        sm = 0
        for x in x_list:
            sm += (x-i)**2
        if mn > sm:
            mn = sm  
    print(mn)
resolve()

### FIXED CODE ###

def resolve():
    n = int(input())
    x_list = list(map(int, input().split()))
    mn = 10**9
    for i in range(1, max(x_list)+1):
        sm = 0
        for x in x_list:
            sm += (x-i)**2
        if mn > sm:
            mn = sm  
    print(mn)
resolve()
n,m=map(int,input().split())
step=list(range(2,n+1))
broken=[]
for i in range(m):
    broken+=[int(input())]
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if not broken[0]==1:
    dp[1]=1
for i in step:
    if not i in broken:
        dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[n])

### FIXED CODE ###

N, M = list(map(int, input().split()))
A = {i: 0 for i in range(N+1)}
mod = 10 ** 9 + 7
for _ in range(M):
    A[int(input())] = 1
 
dp = [0 for _ in range(N+1)]
dp[0] = 1
 
for i in range(N+1):
    if A.get(i+1) == 0:
        dp[i + 1] += dp[i]
    if A.get(i+2) == 0:
        dp[i + 2] += dp[i]
 
print(dp[N]%mod)
N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(N):
  for j in range(N):
    if i /= j:
      ans = ans +d[i] * d[j]
ans = ans / 2
print(ans)

### FIXED CODE ###

n = int(input())
lis = list(map(int,input().split()))
ans = 0
num = sum(lis)
for i in range(n):
  num -= lis[i]
  ans += lis[i] * num
print(ans)