Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[float('inf') for _ in range(10**5+1)] for _ in range(N)]
    dp[0][0] = 0
    dp[0][v[0]] = w[0]

    for i in range(1,N):
        for j in range(10**3*(i+1)+1):
            if j - v[i] >= 0:
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i])
            else:
                dp[i][j] = dp[i-1][j]

    res = 0
    for i,j in enumerate(dp[-1]):
        if j != float("inf") and j <= W:
            res = i
    print(res)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[float('inf') for _ in range(10**5+1)] for _ in range(N)]
    dp[0][0] = 0
    dp[0][v[0]] = w[0]

    js = [0,v[0]]

    for i in range(1,N):
        for j in js[:]:
            js.append(j+v[i])
        js = list(set(js))

        for j in js:
            if j - v[i] >= 0:
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i])
            else:
                dp[i][j] = dp[i-1][j]

    res = 0
    for i,j in enumerate(dp[-1]):
        if j != float("inf") and j <= W:
            res = i
    print(res)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n, k = map(int, input().split())
s = list(input())

seq = []

if s[0] == '1':
    seq.append(0)

prev = s[0]
seq_val = 1
last_seq_length = n
for i in range(1, n):
    if s[i] == prev:
        seq_val += 1
    else:
        last_seq_length -= seq_val
        seq.append(seq_val)
        seq_val = 1
        prev = s[i]

seq += [last_seq_length]

ans = 0
for i in range(n):
    if i % 2 == 0:
        ans = max(ans, sum(seq[i:i+2*k]))
    else:
        ans = max(ans, sum(seq[i:i+2*k+1]))

print(ans)

### FIXED CODE ###

import itertools

n, k = map(int,input().split())
s = input()
seq = []

if s[0] == '0':
    seq.append(0)

i = 1
seq_cnt = 1
while i != n:
    if s[i] != s[i-1]:
        seq.append(seq_cnt)
        seq_cnt = 1
    else:
        seq_cnt += 1
    i += 1

seq.append(seq_cnt)
if s[-1] == '0':
    seq.append(0)

b = [0] + list(itertools.accumulate(seq))

ans = 0
for left in range(0, len(b), 2):
    right = left + 2*k + 1
    if right >= len(b):
        right = len(b)-1

    ans = max(ans, b[right] - b[left])

print(ans)
### BUGGY CODE ###

def IN(): return map(int,input().split())
h,n=IN()
A=[]; dp=[pow(10,9)]*(h+10)
for i in range(n):
  x,y=IN()
  A.append((x,y))
dp[0]=0
for a,b in A:
  for i in range(h):
    if dp[i]==pow(10,9): continue
    index=min(h,i+a)
    dp[index]=min(dp[index],dp[i]+b)
print(dp[h])

### FIXED CODE ###

def IN(): return map(int,input().split())
ans = pow(2,31); mod = pow(10,9)+7
h,n=IN()
A=[]; dp=[pow(2,31)]*111111
for i in range(n):
  x,y=IN()
  A.append((x,y))
dp[0]=0
for a,b in A:
  for i in range(h+1111):
    dp[i+a]=min(dp[i+a],dp[i]+b)
for i in range(h,11111):
  ans=min(ans,dp[i])
print(ans)
### BUGGY CODE ###

N,Q=map(int,input().split())
S=input()
l=[]
for _ in range(Q):
    l=list(map(int,input().split()))
    print(S[(l[0]-1):l[1]].count('AC'))

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
t = [0]*(N+1)
for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
        t[i+1] = 1

import numpy
res = numpy.cumsum(t)

for _ in range(Q):
    l=list(map(int,input().split()))
    print(res[l[1]-1]-res[l[0]-1])
### BUGGY CODE ###

MOD = 998244353
class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

N, A, B, K = map(int, input().split())

n = 2 * min(K // A + 2, N + 1) + 3

lst = Factorial(N + 1, MOD) #O(N)
N_factrorial = lst.factorial(N)
# print (N_factrorial)

def calc(a, b):
    tmp = 0
    G = min(a, b) #緑色の最大値
    # print ('G=', G)
    for green in range(G, -1, -1):
        red = a - green
        blue = b - green
        none_color = N - red - green - blue
        # print (red, green, blue, none_color)
        if none_color < 0:
            break
        tmp += ((((N_factrorial * lst.ifactorial(red) % MOD) * lst.ifactorial(green) % MOD) * lst.ifactorial(blue) % MOD) * lst.ifactorial(none_color) % MOD)
        tmp %= MOD
    return tmp

def count(a, b):
    if a + b > 2 * N:
        return 0
    # print ('to calc')
    return calc(a, b)

ans = 0
for a in range(n): #Aの数
    if A * a > K:
        break
    if (K - A * a) % B != 0:
        continue
    b = (K - A * a) // B
    # print ('a=', a, 'b=', b)
    ans += count(a, b)
    ans %= MOD

print (ans)



### FIXED CODE ###

import numpy as np
MOD = 998244353

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

def gcd(a, b):
    if a > b:
        a, b = b, a
    if b % a == 0:
        return a
    return gcd(b % a, a)

N, A, B, K = map(int, input().split())

if A < B:
    A, B = B, A

# n = 2 * min(K // A + 2, N + 1) + 3
n = min((K + A - 1) // A, N) + 1
lcm = A * B // gcd(A, B)
step = lcm // A

c = Factorial(N + 1, MOD).comb #O(N)

def calc(a, b):
    if a > b:
        a, b = b, a #必ずaのほうが小さくなる
    return (c(N, a) * c(N, b)) % MOD


def count(a, b):
    if a <= N and b <= N:
        return calc(a, b)
    return 0

def maike_satrt(step):
    for i in range(step):
        if (K - A * i) % B == 0:
            return i

start = maike_satrt(step)
# print (start, n)
ans = 0
for a in range(start, n, step): #Aの数
    if A * a > K:
        break
    # if (K - A * a) % B != 0:
    #     continue
    b = (K - A * a) // B
    # print ('a=', a, 'b=', b)
    ans += count(a, b)
    ans %= MOD

print (ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
c = 1
for i in a:
  c = c*i
  
if c > 1E18:
  print(-1)
else:
  print(c)

### FIXED CODE ###

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

def main():
  if 0 in A:
    print(0)
    return
 
  count = 1
  for i in A:
    count *= i
    if count > 1000000000000000000:
      print(-1)
      return
 
  print(count)

main()
### BUGGY CODE ###

N=map(int,input())
A=[int(i) for i in input().split()]

a=1

for i in A:

    a=a*i

if a > 10**(18):
    print(-1)
else:
    print(a)

### FIXED CODE ###

N=map(int,input())
A=[int(i) for i in input().split()]

a=1

if 0 in A:
    print(0)
    exit()

for i in A:

    a=a*i

    if a > 10**(18):
        print(-1)
        exit()


print(a)
### BUGGY CODE ###

n = int(input())
lst = []

for i in range(n):
    s = input()
    if s not in lst:
        lst.append(s)

print(len(lst))


### FIXED CODE ###

n = int(input())
lst = set()

for i in range(n):
    lst.add(input())
    # s = input()
    # if s not in lst:
    #     lst.add(s)

print(len(lst))
### BUGGY CODE ###

n = int(input())
l = []
for i in range(n):
  s = input()
  if s not in l:
    l.append(s)
print(len(l))

### FIXED CODE ###

n = int(input())
l = []
for i in range(n):
  s = input()
  l.append(s)
print(len(set(l)))
### BUGGY CODE ###


class Unionfind:
     
    def __init__(self,n):
        self.uf = [-1]*n
 
    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]
 
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x
        return True
 
    def size(self,x):
        x = self.find(x)
        return -self.uf[x]


n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
xy2 = [[x[0],x[1],i] for (i,x) in enumerate(xy)]
xy2.sort()
u = Unionfind(n)

s = set()
for i,X in enumerate(xy2):
    x,y,ind = X
    check = True
    for j in s:
        if y > xy[j][1]:
            check = False
            u.union(ind,j)
        
    if check:
        s.add(ind)
for i in range(n):
    print(u.size(i))



### FIXED CODE ###

import sys
input = sys.stdin.readline

class Unionfind:
     
    def __init__(self,n):
        self.uf = [-1]*n
 
    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]
 
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x
        return True
 
    def size(self,x):
        x = self.find(x)
        return -self.uf[x]

def main():
    n = int(input())
    xy = [list(map(int,input().split())) for i in range(n)]
    xy2 = [[x[0],x[1],i] for (i,x) in enumerate(xy)]
    xy2.sort()
    u = Unionfind(n)

    l = []
    for x,y,ind in xy2:
        M = y
        le = ind
        while l and xy[l[-1]][1] < y:
            v = l.pop()
            if M > xy[v][1]:
                M = xy[v][1]
                le = v
            u.union(ind,v)
        l.append(le)
    for i in range(n):
        print(u.size(i))

if __name__ == "__main__":
    main()
### BUGGY CODE ###

from math import factorial
n, m, k = map(int, input().split())
MOD = 998244353
ans = 0

def nck(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%MOD


for i in range(k+1):
    ans += (m * nck(n - 1, i) * ((m - 1)**(n - 1 - i)%MOD))
    
print(int(ans%MOD))

### FIXED CODE ###

n, m, k = map(int, input().split())
MOD = 998244353
ans = 0
c = 1

for i in range(k + 1):
    ans += (((m * pow(m - 1, n - i - 1, MOD)) % MOD) * c) % MOD
    ans %= MOD
    c = (c * (n - 1 - i) * pow(i + 1, MOD - 2, MOD)) % MOD
    
    
print(ans%MOD)
### BUGGY CODE ###

n,k = map(int,input().split())

if k==1 :
  ln=0
elif k==0 :
  ln=n
else:
  while 1:
    ln = n
    n = abs(n-k)
    if ln<=n:
      break
print(ln)

### FIXED CODE ###

n,k = map(int,input().split())
 
if k==1 :
  ln=0
elif k==0 :
  ln=n
elif n>=k:
  a = n%k
  n=a
  while 1:
    ln = n
    n = abs(a-k)
    if ln<=n:
      break
else:
  while 1:
    ln = n
    n = abs(n-k)
    if ln<=n:
      break
print(ln)
### BUGGY CODE ###

h, w = map(int, input().split())
grid = ['#' * (h + 2)]
for _ in range(h):
    grid.append('#' + input() + '#')
grid.append('#' * (h + 2))
lgrid = {(i, 0): 0 for i in range(1, h + 1)}
rgrid = {(i, w+1): 0 for i in range(1, h + 1)}
dgrid = {(h+1, i): 0 for i in range(1, w + 1)}
ugrid = {(0, i): 0 for i in range(1, w + 1)}
for i in range(1, h+1):
    for j in range(1, w+1):
        if grid[i][j] == '#':
            lgrid[(i, j)] = 0
            ugrid[(i, j)] = 0
        else:
            lgrid[(i, j)] = lgrid[(i, j - 1)] + 1
            ugrid[(i, j)] = ugrid[(i-1, j)] + 1
        if grid[i][w+1-j] == '#':
            rgrid[(i, w+1-j)] = 0
        else:
            rgrid[(i, w+1-j)] = rgrid[(i, w+2-j)] + 1
        if grid[h+1-i][j] == '#':
            dgrid[(h+1-i, j)] = 0
        else:
            dgrid[(h+1-i, j)] = dgrid[(h+2-i, j)] + 1        
cnt = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        tmp = lgrid[(i,j)]+rgrid[(i,j)]+ugrid[(i,j)]+dgrid[(i,j)] - 3
        cnt = max(cnt, tmp)
print(cnt)


### FIXED CODE ###

h, w = map(int, input().split())
grid = ['#' * (h + 2)]
for _ in range(h):
    grid.append('#' + input() + '#')
grid.append('#' * (h + 2))
lgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
rgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
dgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
ugrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
for i in range(1, h+1):
    for j in range(1, w+1):
        if grid[i][j] == '#':
            lgrid[i][j] = 0
            ugrid[i][j] = 0
        else:
            lgrid[i][j] = lgrid[i][j-1] + 1
            ugrid[i][j] = ugrid[i-1][j] + 1
        if grid[i][w+1-j] == '#':
            rgrid[i][w+1-j] = 0
        else:
            rgrid[i][w+1-j] = rgrid[i][w+2-j] + 1
        if grid[h+1-i][j] == '#':
            dgrid[h+1-i][j] = 0
        else:
            dgrid[h+1-i][j] = dgrid[h+2-i][j] + 1        
cnt = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        tmp = lgrid[i][j]+rgrid[i][j]+ugrid[i][j]+dgrid[i][j] - 3
        cnt = max(cnt, tmp)
print(cnt)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
n,q = map(int,input().split())
to = [[] for _ in range(n)]
ans = [0]*n

for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

for i in range(q): 
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x

def dfs(v,p):
    for u in to[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u,v)

dfs(0,0)
for a in ans: print(a)

### FIXED CODE ###

from collections import deque
n,q = map(int,input().split())
to = [[] for _ in range(n)]
ans = [0]*n

for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

for i in range(q): 
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x

stack = deque()
stack.append((0,0))
while len(stack) != 0:
    cn,pn = stack.pop()
    for nn in to[cn]:
        if nn == pn:
            continue
        ans[nn] += ans[cn]
        stack.append((nn,cn))

print(*ans)
### BUGGY CODE ###

from bisect import bisect
H,W=map(int,input().split())
S=[input() for i in range(H)]
sec_x=[[-1] for i in range(H)]
sec_y=[[-1] for i in range(W)]
for y in range(H):
  for x in range(W):
    if S[y][x]=="#": 
      sec_x[y].append(x)
  sec_x[y].append(W)
for x in range(W):
  for y in range(H):
    if S[y][x]=="#": 
      sec_y[x].append(y)
  sec_y[x].append(H)

ans=0
#print(sec_x)
#print(sec_y)
for y in range(H):
  for x in range(W):
    if S[y][x]!="#":
      a=bisect(sec_x[y],x)
      b=bisect(sec_y[x],y)
      #print(x,y,a,b,sec_x[y][a]-sec_x[y][a-1]+sec_y[x][b]-sec_y[x][b-1]-3)
      ans=max(ans,sec_x[y][a]-sec_x[y][a-1]+sec_y[x][b]-sec_y[x][b-1]-3)
print(ans)    
          
    

### FIXED CODE ###

from bisect import bisect
H,W=map(int,input().split())
S=[input() for i in range(H)]
sec_x=[[-1] for i in range(H)]
sec_y=[[-1] for i in range(W)]
for y in range(H):
  for x in range(W):
    if S[y][x]=="#": 
      sec_x[y].append(x)
  sec_x[y].append(W)
for x in range(W):
  for y in range(H):
    if S[y][x]=="#": 
      sec_y[x].append(y)
  sec_y[x].append(H)

ans=0
#print(sec_x)
#print(sec_y)
for y in range(H):
  l=1
  for x in range(W):
    if S[y][x]=="#":
      l+=1
    else:
      b=bisect(sec_y[x],y)
      #print(x,y,l,b,sec_x[y][l]-sec_x[y][l-1]+sec_y[x][b]-sec_y[x][b-1]-3)
      ans=max(ans,sec_x[y][l]-sec_x[y][l-1]+sec_y[x][b]-sec_y[x][b-1]-3)
print(ans)
### BUGGY CODE ###

n=int(input())
a=[]
count=0
for i in range(0,n):
    word=str(input())
    if not(word in a):
        a.append(word)
        count+=1
print(count)

### FIXED CODE ###

n=int(input())
a=set()
for i in range(0,n):
    b=input()
    a.add(b)
print(len(a))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
ans = []
for i in range(Q):
    b, c = list(map(int, input().split()))
    for j in range(N):
        if A[j] == b:
            A[j] = c

    ans += [sum(A)]
[print(a) for a in ans]

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
AA = {}
t = 0
for a in A:
	t += a
	if a in AA:
		AA[a] += 1
	else:
		AA[a] = 1

Q = int(input())
ans = []
for i in range(Q):
	b, c = list(map(int, input().split()))
	if b in AA:
		if c not in AA:
			AA[c] = 0
		AA[c] += AA[b]
		t += (c - b) * AA[b]
		ans += [t]
		del AA[b]
	else:
		ans += [t]
[print(a) for a in ans]
### BUGGY CODE ###

'''
n = int(input())
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [int(input()) for i in range n]
p = [list(map(int, input().split()))]

a = input()
a, b = input().split()
a = [input() for i in range n]
'''
n = int(input())
x = list(map(int, input().split()))


import math
p0 = math.floor(sum(x)/len(x))
# 123
cost = 0
for i in x:
    cost += abs(p0-i)**2

new = 10**9
while cost < new:
    p0 += 1
    new_cost = 0
    for i in x:
        new_cost += abs(p0-i)**2
    new = new_cost
print(new)


### FIXED CODE ###


n = int(input())
x = list(map(int, input().split()))
cost = 10**9
for i in range(1,100):
    now = 0
    for j in x:
        now += (i-j)**2
    if cost > now:
        cost = now
print(cost)
### BUGGY CODE ###

n, w = map(int, input().split())
dp = [[0] * (w+1) for _ in range(n)]
weight, value = map(int, input().split())
for i in range(weight, w+1):
    dp[0][i] = value
for i in range(n-1):
    weight, value = map(int, input().split())
    for j in range(0, w+1):
        if j < weight:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j - weight] + value)

print(dp[-1][-1])

### FIXED CODE ###

n, w = map(int, input().split())
dp = [[0] * (w+1) for _ in range(n)]
weight, value = map(int, input().split())
for i in range(weight, w+1):
    dp[0][i] = value
for i in range(n-1):
    weight, value = map(int, input().split())
    for j in range(0, w+1):
        if j < weight:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j - weight] + value)

print(dp[-1][-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N = int(input())
L = [int(i) for i in input().split()]
total = 0

L = sorted(L, reverse=True)

for i in range(N-2):
    if L[i+1] + L[i+2] <= L[i]:
        continue
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] < L[j]+L[k] and L[j] < L[i]+L[k] and L[k] < L[i]+L[j]:
                total +=1
            else:
                break

print(total)


### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
L = [int(i) for i in input().split()]
total = 0

L = sorted(L)

for i in range(N-2):
    k = i + 2
    for j in range(i+1, N):
        while k < N and L[i] + L[j] > L[k]:
            k+=1
        if k > j:
            total += k-j-1

print(total)
### BUGGY CODE ###

def ni(n):
    return 3 ** n

def r(x):
    if x=="1":
        return 3
    elif x == "0":
        return 1
    lenx = len(x)
    cur = ni(lenx-1)
    for i in range(1,lenx):
        if x[i] == "1":
            cur += r(x[i:])*2
            break
        elif i == lenx-1:
            cur += 2
    return cur

n = input()
print(r(n)%1000000007)

### FIXED CODE ###

L = input()
waru = 1000000007
lis1 = 1
lis2 = 2
for i in range(1,len(L)):
    if L[i] == "0":
        lis1 = (lis1*3) % waru
        lis2 = lis2 % waru
    elif L[i] == "1":
        lis1 = (lis1*3+lis2) % waru
        lis2 = (lis2*2) % waru

print((lis1+lis2) % waru)
### BUGGY CODE ###

A, B, N = map(int, input().split())  # 入力

ans = None
a_max = None

for _x in range(N):
    x = min((B - 1), N) * (_x+1)
    if x > N:
        break
    # print(x)
    a = x/B-int(x / B)
    # print(int(a * A))
    sa = int(a*A)
    # s = int((A * x) / B) - A * int(x / B)
    if a_max == None:
        a_max = sa
    elif sa > a_max:
        a_max = sa

print(a_max)


### FIXED CODE ###

A, B, N = map(int, input().split())  # 入力

ans = None
a_max = None

for _x in range(1):
    x = min((B - 1), N) * (_x+1)
    if x > N:
        break
    # print(x)
    a = x/B-int(x / B)
    # print(int(a * A))
    sa = int(a*A)
    # s = int((A * x) / B) - A * int(x / B)
    if a_max == None:
        a_max = sa
    elif sa > a_max:
        a_max = sa

print(a_max)
### BUGGY CODE ###

N, M = map(int, input().split())
L = list(map(int, input().split()))

if N == 1:
	if L[0]%M == 0:
		print(1)
		exit()
	else:
		print(0)
		exit()

for i in range (0, N):
	L[i] = L[i]%M

count = 0

for i in range (1, N):
	L[i]+= L[i-1]
    
for i in range (0, N):
	L[i] = L[i]%M

L = sorted(L)

alreadythere = []

for i in range (0, N):
	if alreadythere.count(L[i])>0 or L[i] == 0:
		continue
	else:
		alreadythere.append(L[i])
		V = L[i]
		D = L.count(L[i])
		count+= int(D*(D-1)/2)

V = L.count(0)
count+= V+int(V*(V-1)/2)

print(count)

### FIXED CODE ###

N, M = map(int, input().split())
L = list(map(int, input().split()))

if N == 1:
	if L[0]%M == 0:
		print(1)
		exit()
	else:
		print(0)
		exit()

for i in range (0, N):
	L[i] = L[i]%M

count = 0

for i in range (1, N):
	L[i]= (L[i-1]+L[i])%M

L = sorted(L)

alreadythere = []
import collections

cnt = collections.Counter()
for number in L:
	cnt[number] += 1

L = set(L)

for i in L:
	if i == 0:
		K = cnt[i]
		count+=(int(K*(K-1)/2)+K)
	else:
		K = cnt[i]
		count+=int(K*(K-1)/2)

print(count)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
b=list(set(a))
num=[]
for i in range(len(b)):
  if a.count(b[i])>b[i]:
    num.append(a.count(b[i])-b[i])
  elif a.count(b[i])<b[i]:
    num.append(a.count(b[i]))
print(sum(num))

### FIXED CODE ###

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

a=sorted(a)
l=a[0]
cnt=0

b=[]
for i in range(N):
    if a[i]==l:
        cnt+=1
    else:
        b.append([l,cnt])
        l=a[i]
        cnt=1
if cnt>0:
    b.append([l,cnt])

ans=0
for i in range(len(b)):
    if b[i][0]>b[i][1]:
        ans+=b[i][1]
    else:
        ans+=b[i][1]-b[i][0]

print(ans)