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

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

num_set = set()
for a_i in a:
    if a_i in num_set:
        continue
    num_set.add(a_i)

ans = 0
for num in num_set:
    num_of_num = a.count(num)
    # print(num, num_of_num)
    if num == num_of_num:
        continue
    if num_of_num < num:
        ans += num_of_num
        continue
    ans += num_of_num-num

print(ans)

### FIXED CODE ###

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

num_dict = dict()
for a_i in a:
    if a_i in num_dict:
        num_dict[a_i] += 1
        continue
    num_dict[a_i] = 1

ans = 0
for num in num_dict:
    if num_dict[num] == num:
        continue
    if num_dict[num] < num:
        ans += num_dict[num]
        continue
    ans += num_dict[num]-num

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

#!/usr/bin/env python3
def main():
    _ = int(input())
    A = [int(x) for x in input().split()]
    Q = int(input())

    sum_A = sum(A)
    for _ in range(Q):
        B, C = map(int, input().split())

        sum_A = sum_A + A.count(B) * (C - B)
        print(sum_A)
        A = [C if x == B else x for x in A]


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

    _ = int(input())
    lst = [0 for _ in [0] * (10 ** 5 + 1)]
    sum_lst = 0
    for a in [int(x) for x in input().split()]:
        sum_lst += a
        lst[a] += 1
    Q = int(input())

    for _ in range(Q):
        B, C = map(int, input().split())

        sum_lst += (C - B) * lst[B]
        print(sum_lst)
        lst[C] += lst[B]
        lst[B] = 0


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

n,m=map(int,input().split());a,b=[],[]
for i in range(n):
  aa,bb=map(int,input().split())
  a.append(aa);b.append(bb)
#---c.sorted(a)---
c=a[:]
def swap(ab,ba,X):
  abc=X[ab]
  X[ab]=X[ba]
  X[ba]=abc
h=n
while 1:
  hh=c[:]
  if h>1:h=round(h//1.3)
  for i in range(n-h):
    if c[i]>c[i+h]:swap(i,i+h,c)
  if hh==c and h==1:break
#---------
s,ans=0,0
for i in c:
  j=a.index(i)
  k=min(b[j],m-s)
  s+=k
  ans+=a[j]*k
  a[j]=-1
  if m==s:break
print(ans)

### FIXED CODE ###

n,m=map(int,input().split());d,ans=[],0
for i in range(n):d.append(list(map(int,input().split())))
d.sort()
for i in range(n):
  if d[i][1]<=m:
    ans+=d[i][0]*d[i][1]
    m-=d[i][1]
  else:
    ans+=d[i][0]*m
    m=0
  if m<=0:break
print(ans)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
s = list(input())
for i in range(int(input())):
    q, l, r = input().split()
    q = int(q)
    l = int(l) - 1
    if q == 1:
        if s[l] != r:
            s[l] = r
    else:
        print(len(set(s[l:int(r)])))


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from operator import or_


class SegmentTree:
    def __init__(self, orig, func, unit):
        _len = len(orig)
        self.func = func
        self.size = 1 << (_len - 1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] * (self.size - _len)
        self.unit = unit

        for i in range(self.size - 1, 0, -1):
            self.tree[i] = func(self.tree[i * 2], self.tree[i * 2 + 1])

    def update(self, i, v):
        i += self.size
        self.tree[i] = v
        while i:
            i //= 2
            self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

    def find(self, l, r):
        l += self.size
        r += self.size
        ret = self.unit
        while l < r:
            if l & 1:
                ret = self.func(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.func(ret, self.tree[r])
            l //= 2
            r //= 2
        return ret


n = readline()
s = readline()
q = int(readline())
li = [1 << ord(x) - 97 for x in s[:-1]]
seg = SegmentTree(li, or_, 0)
ans = []
for _ in range(q):
    f, x, y = readline().split()
    x = int(x)
    if f == '1':
        seg.update(x - 1, 1 << ord(y) - 97)
    else:
        y = int(y)
        z = seg.find(x - 1, y)
        cnt = bin(z).count('1')
        ans.append(cnt)
print(*ans)
### BUGGY CODE ###

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

pins = []

for i in range(1000):
    # 確認するpinの数字の組み合わせと桁の初期化
    pin = f'{i:0>3}'
    current_digit = 0

    for num in s:
        # 見つけると桁を右に一つずらす
        if num == pin[current_digit]:
            current_digit += 1
            # indexが3(桁が3→2→1→0)になったときはそのPINは作れる
            if current_digit == 3:
                pins.append(pin)
                break

print(len(pins))

### FIXED CODE ###

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

ans = 0

for i in range(1000):
    # 確認するpinの数字の組み合わせと桁の初期化
    current_digit = 0
    pin = f'{i:0>3}'
    # pin = list(str(i).zfill(3))
    k = pin[current_digit]

    for num in s:
        # 見つけると桁を右に一つずらす
        if num == k:
            current_digit += 1
            # indexが3(桁が3→2→1→0)になったときはそのPINは作れる
            if current_digit <= 2:
                k = pin[current_digit]

            elif current_digit == 3:
                ans += 1
                break

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

import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))
d = collections.Counter(a)
ans = 0

while len(d.keys()) > k:
    min_kv = min(d.items(), key=lambda x: x[1])
    ans += min_kv[1]
    del d[min_kv[0]]

print(ans)



### FIXED CODE ###

import collections
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
a = list(map(int, input().split()))
d = collections.Counter(a)
v = list(d.values())
v = sorted(v)

ans = 0
i = 0
while len(v) - i > k:
    ans += v[i]
    i += 1

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

import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')


def solve(n, k, a):
    # wia(a)
    for _ in range(k):
        b = [0] * n
        reached = 0
        for i in range(n):
            for j in range(max(0, i - a[i]), min(n, i + a[i] + 1)):
                b[j] += 1
                if b[j] == n:
                    reached += 1
        a = b
        # wia(a)
        if reached == n:
            break
    return a


def main():
    n, k = ria()
    a = ria()
    wia(solve(n, k, a))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')


def solve(n, k, a):
    # wia(a)
    for _ in range(k):
        b = [0] * n
        for i in range(n):
            l = max(0, i - a[i])
            r = min(n-1, i + a[i])
            b[l] += 1
            if r < n-1:
                b[r+1] -= 1
        for i in range(1, n):
            b[i] += b[i-1]
        a = b
        # wia(a)
        if sum(a) == n * n:
            break
    return a


def main():
    n, k = ria()
    a = ria()
    wia(solve(n, k, a))


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

s = input()

s = s[::-1]
s += "0"
l = len(s)

dp = [[float("inf")] * 2 for _ in range(l + 1)]
dp[0][0] = 0

for i, e in enumerate(s):
    for j in range(2):
        x = int(e)
        x += j
        for a in range(10):
            ni = i + 1
            nj = 0
            b = a - x
            if b < 0:
                nj = 1
                b += 10

            dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b)

ans = dp[l][0]
print(ans)


### FIXED CODE ###

s = input()

s = s[::-1]
s += "0"
l = len(s)

dp = [[float("inf")] * 2 for _ in range(l + 1)]
dp[0][0] = 0

for i, e in enumerate(s):
    for j in range(2):
        x = int(e)
        x += j
        for a in range(10):
            ni = i + 1
            nj = 0
            b = a - x
            if b < 0:
                nj = 1
                b += 10

            dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b)

ans = dp[l][0]
print(ans)
### BUGGY CODE ###

n=int(input())

list=[]

for i in range(1,n+1):
    a=n%i
    if a == 0:
        if(i<n/i):
            list.append([i,int(n/i)])
        else:
            list.append([int(n/i),i])
            if i>1 :
                if len(list) == 1:
                    ans=(list[-1][0]-1)+(list[-1][1]-1)
                    break
                if list[-1]==list[-2]:
                    ans=(list[-1][0]-1)+(list[-1][1]-1)
                    break
print(ans)

### FIXED CODE ###

import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break
### BUGGY CODE ###

import math
N,M = list(map(int,input().split()))
a = [-1]
for i in range(M):
    a.append(int(input()))
a.append(N+1)
b = []
c = []
fac_N =[1]
#for i in range(M+1):
#    b.append(a[i+1]-a[i]-2)
for i in range(1,(N+1)):
    fac_N.append(fac_N[-1]*i)


for i in range(M+1):
    counter= 0
    for num2 in range((a[i+1]-a[i]-2)//2+1):
        counter += fac_N[num2+((a[i+1]-a[i]-2)-2*num2)]//fac_N[num2]//fac_N[(a[i+1]-a[i]-2)-2*num2]%1000000007
    c.append(counter)
ans = 1
for i in range(len(c)):
    ans *= c[i]%1000000007
print(ans%1000000007)


### FIXED CODE ###

n,m = map(int,input().split())
a = [ int(input()) for _ in range(m)]
M=10**9+7
lis = [1] + [0]*n

for i in a:
  lis[i]=-1
lis[1] += 1
for i in range(n-1):
  if lis[i+2]<0:
    lis[i+2]= 0
  else:
    lis[i+2] = (lis[i+1] + lis[i])%M
print(lis[n])
### BUGGY CODE ###

def main():
    from collections import deque
    N,M = map(int, input().split())
    A = deque(map(int, input().split()))
    for _ in range(M):
        B,C=map(int, input().split())
        A.extend([C for _ in range(B)])
    A = list(A)
    A.sort()
    print(sum(A[len(A)-N:]))

main()

### FIXED CODE ###

n,m=map(int,input().split())
ans=list(map(int,input().split()))
arr=[list(map(int,input().split())) for _ in range(m)]
arr=sorted(arr,reverse=True,key=lambda x:x[1])
tmp=0
for cnt,val in arr:
  ans+=[val]*cnt
  tmp+=cnt
  if tmp>=n:
    break
ans=sorted(ans,reverse=True)
print(sum(ans[:n]))
### BUGGY CODE ###

N, M =map(int, input().split())
Ps =[]
Ys =[]
ls = []
for i in range(N):
    ls.append([])
for i in range(M):
    p, y = map(int, input().split())
    Ps.append(p)
    Ys.append(y)
    ls[p-1].append(y)
for l in ls:
    l.sort()
for i in range(M):
    p = Ps[i]
    y = Ys[i]
    number = ls[p-1].index(y) + 1
    strp = str(p)
    strn = str(number)
    print(strp.zfill(6) + strn.zfill(6))


### FIXED CODE ###

N, M =map(int, input().split())
ls = []
pcount =[]
for i in range(N):
    pcount.append(0)
for i in range(M):
    p, y = map(int, input().split())
    ls.append([i, p, y])
ls.sort(key = lambda x:x[2])

for l in ls:
    pcount[l[1]-1] += 1
    l.append(pcount[l[1]-1])
ls.sort(key = lambda x:x[0])
for l in ls:
    print(str(l[1]).zfill(6) + str(l[3]).zfill(6))
### BUGGY CODE ###

from collections import deque
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7

S = str(input())
N = len(S)
ans = [0]*N
k = int(1)
R = deque()
L = deque()
rcount = int(1)
lcount = int(0)
lLocate = deque()
for i in range(1,N):
    if S[i]==S[i-1]:
        if k == 1:
            rcount +=1
        else:
            lcount +=1
    else:
        if k==1:
            R.append(rcount)
            lLocate.append(i-1)
            lcount = int(1)
        else:
            L.append(lcount)
            rcount = int(1)

        k *= (-1)


L.append(lcount)

#print(R)
#print(L)
#print(lLocate)
#j = int(0)
for i in range(N):
    if i in lLocate:
        r = R.popleft()
        l = L.popleft()
        ans[i] = (r+1)//2 + l//2
        ans[i+1] = r//2 + (l+1)//2
#        j +=1

print(' '.join(map(str, ans)))

### FIXED CODE ###

#from collections import deque
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7

S = str(input())
N = len(S)
ans = [0]*N
k = int(1)
R = []
L = []
rcount = int(1)
lcount = int(0)
lLocate = []
for i in range(1,N):
    if S[i]==S[i-1]:
        if k == 1:
            rcount +=1
        else:
            lcount +=1
    else:
        if k==1:
            R.append(rcount)
            lLocate.append(i-1)
            lcount = int(1)
        else:
            L.append(lcount)
            rcount = int(1)

        k *= (-1)


L.append(lcount)

#print(R)
#print(L)
#print(lLocate)
j = int(0)
#for i in range(N):
#    if i in lLocate:
for i in lLocate:
    r = R[j]
    l = L[j]
    ans[i] = (r+1)//2 + l//2
    ans[i+1] = r//2 + (l+1)//2
    j +=1

print(' '.join(map(str, ans)))
### BUGGY CODE ###

N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
A = [0] + A
for i in range(1, N + 1):
    A[i] += A[i - 1]

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

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

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N, K = map(int, input().strip().split(" "))
A = list(map(int, input().strip().split(" ")))
A = [0] + A
for i in range(1, N + 1):
    A[i] += A[i - 1]
    A[i - 1] -= i - 1
A[N] -= N

rem_count = {}
rem_count[0] = 1
ans = 0
for i in range(1, N + 1):
    if i - K >= 0:
        rem_count[A[i - K] % K] -= 1
    if A[i] % K in rem_count:
        ans += rem_count[A[i] % K]
        rem_count[A[i] % K] += 1
    else:
        rem_count[A[i] % K] = 1

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

state = list(map(int,input().strip().split(' ')))
states = [state]
flag=True
counterlist=[]
counterlist.append(0)

def procedure1(s,c):
    #case1
    states.append([s[0]+1, s[1]+1, s[2]])
    counterlist.append(c+1)
    
    #case2
    states.append([s[0]+1, s[1], s[2]+1])
    counterlist.append(c+1)
    
    #case3
    states.append([s[0], s[1]+1, s[2]+1])
    counterlist.append(c+1)
    
def procedure2(s,c):
    #case1
    states.append([s[0]+2, s[1], s[2]])
    counterlist.append(c+1)
    
    #case2
    states.append([s[0], s[1]+2, s[2]])
    counterlist.append(c+1)
    
    #case3
    states.append([s[0], s[1], s[2]+2])
    counterlist.append(c+1)

while flag:
    s = states.pop(0) 
    c = counterlist.pop(0)
    if s[0]==s[1] and s[1]==s[2]:
        flag=False
        print(c)

    procedure1(s,c)
    procedure2(s,c)

### FIXED CODE ###

states = list(map(int,input().strip().split(' ')))
sortedlist = sorted(states)

diff0 = (sortedlist[2]-sortedlist[0])//2
diff1 = (sortedlist[2]-sortedlist[1])//2

newlist = [sortedlist[0]+2*diff0, sortedlist[1]+2*diff1, sortedlist[2]]

def patternMatch(s):
    if 1==2*s[2]-s[1]-s[0]:
        return 2
    elif 2==2*s[2]-s[1]-s[0]:
        return 1
    elif 0==2*s[2]-s[1]-s[0]:
        return 0

print(patternMatch(newlist)+diff0+diff1)
### BUGGY CODE ###

n = input()
  
A = map(int, raw_input().split())
   
q = input()
   
M = map(int, raw_input().split())
  
def solve(i, m):
  if m == 0:
    return True
  if i >= n:
    return False
  res = solve(i+1, m) or solve(i+1, m - A[i])
  return res
  
  
for m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"

### FIXED CODE ###

n = input()

A = map(int, raw_input().split())
   
q = input()
   
M = map(int, raw_input().split())
  
def solve(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A):
    return False
  res = solve(i+1, m) or solve(i+1, m - A[i])
  return res
  
  
for m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"
### BUGGY CODE ###

*D, = open(0)
n = int(D[0])

edge = [[] for _ in range(n+1)]
v_val = [0 for _ in range(n+1)]

dist = {}

for i in range(1, n):
    a, b = map(int, D[i].split())
    edge[a].append(b)
    edge[b].append(a)
c = list(map(int, D[n].split()))

c = sorted(c, reverse=True)

def calcCost(D, v_val):
    total = 0
    
    n = int(D[0])
    for i in range(1, n):
        a, b = map(int, D[i].split())
        total += min(v_val[a], v_val[b])
        
    return total

# naive
import itertools
max_val = 0
max_v = 0
for it in itertools.permutations(c):
    v_val = [0] + list(it)
    val = calcCost(D, v_val)
    if val > max_val:
        max_val = val
        max_v = v_val
print(max_val)
print(' '.join(map(str, max_v[1:])))

### FIXED CODE ###

*D, = open(0)
n = int(D[0])

edge = [[] for _ in range(n+1)]
v_val = [0 for _ in range(n+1)]

dist = {}

for i in range(1, n):
    a, b = map(int, D[i].split())
    edge[a].append(b)
    edge[b].append(a)
c = list(map(int, D[n].split()))
c = sorted(c, reverse=True)

from collections import deque
visited = [False for _ in range(len(edge))]
start = 1
que = deque()
que.append(start)
order = []
order.append(start)
visited[start] = True

while que:
    node = que.popleft()
    for it in edge[node]:
        if not visited[it]:
            order.append(it)
            visited[it] = True
            que.append(it)
# calculate cost
v_val = [0 for _ in range(len(c)+1)]
for i, it in enumerate(order):
    v_val[it] = c[i]

print(sum(c[1:]))
print(' '.join(map(str, v_val[1:])))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N,M=map(int,input().split())
list1=list(map(int,input().split()))
for _ in range(M):
  B,C=map(int,input().split())
  list1+=[C]*B
  for _ in range(B):
    list1.remove(min(list1))
SUM=sum(list1)
print(SUM)

### FIXED CODE ###

N,M = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort()
 
listBC = [list(map(int, input().split())) for i in range(M)]
listBC = sorted(listBC, key=lambda x: x[1], reverse=True)
countB = 0
 
for i in range(M):
  B, C = listBC[i][0], listBC[i][1]
  listA += [C]*B
  countB += B
  if countB >= N:
    break

listA.sort(reverse=True)
print(sum(listA[:N]))
### BUGGY CODE ###

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

a.sort()

a2 = []
for i, x in enumerate(a):
  a2.append((x, i))

from math import factorial


def c(n, r):
  if n - r < 0:
    return 0
  return factorial(n) // factorial(r) // factorial(n - r)


ma = 0
mi = 0
for i in range(n):
  ma += a[i] * c(i, k - 1)
  mi += a[i] * c(n - i - 1, k - 1)

MOD = 10**9 + 7
print((ma - mi) % MOD)


### FIXED CODE ###

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

a.sort()

a2 = []
for i, x in enumerate(a):
  a2.append((x, i))

from math import factorial


def c(n, r):
  if n - r < 0:
    return 0
  return factorial(n) // factorial(r) // factorial(n - r)


MOD = 10**9 + 7  # 出力の制限

# https://qiita.com/derodero24/items/91b6468e66923a87f39f


def cmb(n, r):
  if (r < 0 or r > n):
    return 0
  r = min(r, n - r)
  return g1[n] * g2[r] * g2[n - r] % MOD


g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, n + 1):
  g1.append((g1[-1] * i) % MOD)
  inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD)
  g2.append((g2[-1] * inverse[-1]) % MOD)


ma = 0
mi = 0
for i in range(n):
  ma += a[i] * cmb(i, k - 1)
  mi += a[i] * cmb(n - i - 1, k - 1)

print((ma - mi) % MOD)
### BUGGY CODE ###

X, Y = map(int, input().split())

for x in range(1, 10**18):
    if x % X == 0:
        if x % Y != 0:
            ans = x
            break
        else:
            ans = -1
print(ans)

        

### FIXED CODE ###

X,Y = map(int, input().split())

if X % Y == 0:
    print(-1)
else:
    print(X)
### BUGGY CODE ###

n = int(input())
s = list(input())
numcount = [0] * 10
ans = 0
for i in s:
    numcount[int(i)] += 1
for i in range(10):
    for j in range(10):
        for k in range(10):
            c = 0
            if numcount[i] == 0 or numcount[j] == 0 and numcount[k] == 0:
                continue
            elif ((i == j or i == k) and numcount[i] <= 1) or (j == k and numcount[j] <= 1):
                continue
            elif i == j == k and numcount[i] <= 2:
                continue
            else:
                c, l = 0, 0
                m = [i, j, k]
                while True:
                    if m[l] == int(s[c]):
                        l += 1
                    c += 1
                    if l == 3:
                        ans += 1
                        break
                    if c == n:
                        break
print(ans)

### FIXED CODE ###

n = int(input())
s = list(input())
numcount = [0] * 10
ans = 0
for i in s:
    numcount[int(i)] += 1
for i in range(10):
    for j in range(10):
        for k in range(10):
            c = 0
            if numcount[i] == 0 or numcount[j] == 0 and numcount[k] == 0:
                continue
            elif ((i == j or i == k) and numcount[i] <= 1) or (j == k and numcount[j] <= 1):
                continue
            elif i == j == k and numcount[i] <= 2:
                continue
            else:
                c, l = 0, 0
                m = [i, j, k]
                while True:
                    if m[l] == int(s[c]):
                        l += 1
                    c += 1
                    if l == 3:
                        ans += 1
                        break
                    if c == n:
                        break
print(ans)
### BUGGY CODE ###

N, K = list(map(int, input().split()))
AA = list(map(int, input().split()))
A = [0] + AA
DP = [[0 for i in range(N+1)] for k in range(61)]

for i in range(1, N+1):
	DP[0][i]=A[i]
for k in range(1, 61):
    for i in range(1, N+1):
        DP[k][i] = DP[k-1][DP[k-1][i]]

now = 1
for k in range(61):
	if (K>>k) & 1:
		now = DP[k][now]

print(now)

### FIXED CODE ###

N, K = list(map(int, input().split()))
AA = list(map(int, input().split()))
A = [0] + AA
DP = [[0 for i in range(N+1)] for k in range(61)]

for i in range(1, N+1):
	DP[0][i]=A[i]
for k in range(1, 61):
    for i in range(1, N+1):
        DP[k][i] = DP[k-1][DP[k-1][i]]

now = 1
for k in range(61):
	if (K>>k) & 1:
		now = DP[k][now]

print(now)
### BUGGY CODE ###

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

ans = 0
for i in range(n-1):
    t = a[i] + a[i+1]
    s = int(a[i] ^ a[i+1])
    while t == s:
        ans += 1
        if i == n-2:
            break
        i += 1
        t = t + a[i+1]
        s = int(s ^ a[i+1])
print(ans+n)


### FIXED CODE ###

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

l = 0
r = 0
ans = 0
sum = A[0]
xor = A[0]
while True:
    if sum == xor:
        ans += r-l+1
        if r == n-1:
            break
        r += 1
        sum += A[r]
        xor ^= A[r]
    else:
        sum -= A[l]
        xor ^= A[l]
        if l == n-1:
            break
        l += 1

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

INF = 2**60 # 無限大を表す値
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(N)]
dp = [INF] * (H + 1)
dp[0] = 0
for (A, B) in AB:
    for j in range(H+1):
        dp[j] = min(dp[j], dp[max(j-A, 0)] + B)
print(dp[H])

### FIXED CODE ###

INF = 2**60 # 無限大を表す値
H, N = map(int, input().split())
AB = [map(int, input().split()) for i in range(N)]
dp = [INF] * (H + 1)
dp[0] = 0
for A, B in AB:
    for j in range(H+1):
        dp[j] = min(dp[j], dp[max(j-A, 0)] + B)
print(dp[H])
### BUGGY CODE ###

n,k = map(int,input().split())
mod = 10**9+7

l = [0]*(k+1)

for i in range(k,0,-1):
  m = k//i
  l[i] += m**n
  for j in range(2,m+1):
    l[i] -= l[i*j]

ans = 0
for i in range(k+1):
  ans += i*l[i] % mod
  ans %= mod
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
mod = 10**9+7

l = [0]*(k+1)

for i in range(k,0,-1):
  m = k//i
  l[i] += pow(k//i,n,mod)
  for j in range(2,m+1):
    l[i] -= l[i*j]

ans = 0
for i in range(k+1):
  ans += i*l[i] % mod
  ans %= mod
print(ans)
### BUGGY CODE ###

n = int(input())
h = list(map(int, input().split()))
ans = 0

if len(h) != 1:
    for i in range(len(h) - 1):
        if h[i] - 2 >= min(h[i+1:]):
            ans = 1
            break

if ans == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = int(input())
h = [0] + list(map(int, input().split()))

for i in range(n):
    if h[i] < h[i+1]:
        h[i+1] -= 1
    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')