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

n = int(input())
li = list(map(int,input().split()))
li.sort()
dp = [1]*n
done = [0]*n

for i in range(n):
    if done[i]==1:
        continue
    for j in range(i+1,n):
        if done[j]==1:
            continue
        if li[j]%li[i]==0:
            done[j]=1
            dp[j]=0
        if li[j]==li[i]:
            done[i]=1
            dp[i]=0
            
print(sum(dp))

### FIXED CODE ###

n  = int(input())
li = list(map(int,input().split()))
ok = set()
ng = set()
mul = set()

ans = 0

for i in li:
    if i not in ok:
        ok.add(i)
    else:
        ng.add(i)

for i in ok:
    for j in range(2,10**6):
        if i*j > 10**6:
            break
        else:
            mul.add(i*j)

for i in ok:
    if i not in mul:
        if i not in ng:
            ans+=1

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

from sys import stdin


def a(input_string):
    N, M = [int(x) for x in input_string[0].split()]
    C = input_string[1:]
    temp = [string.split() for string in C]
    D = []
    for i in range(len(temp)):
        D.append([int(word) for word in temp[i]])
    #print(D)
    get_count = 0
    min_cost = 10000000000000000
    cost = 0
    D = sorted(D, key=lambda x: x[0])
    for i in range(N):
        for j in range(D[i][1]):
            get_count += 1
            cost += D[i][0]
            if get_count >= M:
                if cost < min_cost:
                    min_cost = cost
    return min_cost


def main():
    input_line = stdin.readlines()
    answer = a(input_line)
    print(answer)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from sys import stdin


def a(input_string):
    N, M = [int(x) for x in input_string[0].split()]
    C = input_string[1:]
    temp = [string.split() for string in C]
    D = []
    for i in range(len(temp)):
        D.append([int(word) for word in temp[i]])
    #print(D)
    get_count = 0
    min_cost = 10000000000000000
    cost = 0
    D = sorted(D, key=lambda x: x[0])
    for i in range(N):
        for j in range(D[i][1]):
            get_count += 1
            cost += D[i][0]
            if get_count >= M:
                return cost
    return cost


def main():
    input_line = stdin.readlines()
    answer = a(input_line)
    print(answer)


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

from collections import defaultdict

def main():
    num, person_num = map(int, input().split())
    data = list(map(int, input().split()))

    dp = [defaultdict(int) for i in range(num)]
    dp[0][data[0] % person_num] += 1

    ans = 0
    for i in range(1, num):
        now_data = data[i]
        ans += dp[i - 1][0]
        for key in dp[i - 1].keys():
            now_ind = (key + now_data) % person_num
            dp[i][now_ind] += dp[i - 1][key]
        dp[i][now_data % person_num] += 1

    ans += dp[num - 1][0]

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###


from collections import defaultdict


def main():
    num_box, num_people = map(int, input().split())
    data = list(map(int, input().split()))

    dp = defaultdict(int)
    dp[0] += 1
    count = 0
    for i in range(num_box):
        count += data[i]
        count %= num_people
        dp[count] += 1

    ans = 0
    for ele in dp.values():
        if ele >= 2:
            ans += (ele - 1) * ele // 2

    print(ans)





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

x=int(input())
for i in range(int(x**.5+1)):
  for j in range(-int((x**.5+1)),int(x**.5+1)):
    if i**5-j**5==x:
      print(i,j)
      exit()

### FIXED CODE ###

x=int(input())
for i in range(int(x**.3+1)):
  for j in range(-int((x**.3+1)),int(x**.3+1)):
    if i**5-j**5==x:
      print(i,j)
      exit()
### BUGGY CODE ###

from operator import mul
from functools import reduce

N = int(input())
L = list(map(int, input().split()))
M = reduce(mul, L)
if 10 ** 18 < M:
    M = -1
print(M)

### FIXED CODE ###

import sys
O = pow(10, 18)
N = int(input())
L = list(map(int, input().split()))
M = 1

if 0 in L:
    print(0)
    sys.exit()

for i in range(N):
    M = M * L[i]
    if O < M:
        print(-1)
        sys.exit()
    else:
        continue
print(M)
### BUGGY CODE ###

n = int(input())
wordlist = [input() for i in range(n)]
wordlist2 = list(set(wordlist))
ans = []
maxnum = 0
for j in range(len(wordlist2)) :
    countnum = wordlist.count(wordlist2[j])
    if countnum == maxnum :
        ans.append(wordlist2[j])
    if countnum > maxnum :
        maxnum = countnum
        ans = []
        ans.append(wordlist2[j])
    while wordlist2[j] in wordlist :
        wordlist.remove(wordlist2[j])
ans.sort()
for l in range(len(ans)) :
    print(ans[l])

### FIXED CODE ###

n = int(input())
d = {}
for i in range(n) :
    s = input()
    if s not in d :
        d[s] = 1
    else :
        d[s] += 1
m = max(d.values())
ans = []
for i in d :
    if d[i] == m :
        ans.append(i)
ans.sort()
for i in ans:
    print(i)
### BUGGY CODE ###


def nthNum(nMinusOneNum):
    return nMinusOneNum*10 + 7

K = int(input())

crawler = 7
i = 0

if (K % 2 ==0):
    print(-1)
else:
    while True:
        if crawler%K == 0:
            print(i + 1)
            break
        temp = nthNum(crawler)
        crawler = temp;
        i += 1


### FIXED CODE ###

def main():
    K = int(input())

    crawler = 7
    found = False
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        a[0] = a[0] % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
        if not found:
            print(-1)
    
main()
### BUGGY CODE ###

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    for i in range(n):
        a_copy = list(a)
        a_copy.pop(i)
        print(max(a_copy))

main()

### FIXED CODE ###

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    a_copy = sorted(a)
    a_max = a_copy[-1]
    a_second = a_copy[-2]
    for i in range(n):
        if a[i] == a_max:
            print(a_second)
        else:
            print(a_max)


main()
### BUGGY CODE ###

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

count = 0

x = 0
y = 0
z = 0

for targetX in range(ks[0]+1):
    
    
    if targetX <= ks[0] and ks[1]-(targetX+ks[0]+ks[0]) <= 0:
    
        for targetY in range(ks[0]+1):
            
            if targetY <= ks[0]:
        
                for targetZ in range(ks[0]+1):
                
                    if targetZ <= ks[0]:
                        
                        if targetX + targetY + targetZ == ks[1]:
                            count +=1
                    
                    targetZ +=1
        
            targetY +=1
        
    targetX +=1
        

print(count)


### FIXED CODE ###

ks= list(map(int, input().split())) 
 
count = 0
 
x = 0
y = 0
z = 0
 
for targetX in range(ks[0]+1):
    
    
    if targetX <= ks[0] and ks[1]-(targetX+ks[0]+ks[0]) <= 0:
    
        for targetY in range(ks[0]+1):
            
            z = ks[1] - (targetX + targetY)
            
            if 0 <= z and z <= ks[0]:
                count += 1
                
        
        
        
 
print(count)
### BUGGY CODE ###

import math

X = int(input())

def decompose(n):
	result = []
	half = math.floor(math.sqrt(n))
	i = 2
	while i <= half:
		if n % i == 0:
			result.append(i)
			n //= i
			half = math.floor(math.sqrt(n))
		else:
			i += 1
	if n > 1:
		result.append(n)
	return result

facts = decompose(X)

fact_table = {}
for f in facts:
	if f not in fact_table:
		fact_table[f] = 1
	else:
		fact_table[f] += 1

facts = list(fact_table.items())
facts.sort()

def find(num, n):
	if n >= len(facts):
		A = 0
		while True:
			B = A - num
			x = A ** 5 - B ** 5
			if x == X:
				return A, B
			elif B > 0 and x > X:
				break
			A += 1
	else:
		f, c = facts[n]
		for i in range(c + 1):
			ret = find(num, n + 1)
			if ret != None:
				return ret
			num *= f
	return None

A, B = find(1, 0)


print(A, B)


### FIXED CODE ###

import math

X = int(input())

def decompose(n):
	result = []
	half = math.floor(math.sqrt(n))
	i = 2
	while i <= half:
		if n % i == 0:
			result.append(i)
			n //= i
			half = math.floor(math.sqrt(n))
		else:
			i += 1
	if n > 1:
		result.append(n)
	return result

facts = decompose(X)

fact_table = {}
for f in facts:
	if f not in fact_table:
		fact_table[f] = 1
	else:
		fact_table[f] += 1

facts = list(fact_table.items())
facts.sort()

def bisearch_smallest(f, s, e = None):
	if e == None:
		e = s - 1
		s = 0
	else:
		e -= 1
	
	while s < e:
		m = (s + e) // 2
		if f(m):
			e = m
		else:
			s = m + 1
	
	if s == e and f(s):
		return s
	else:
		return -1

def find(num, n):
	if n >= len(facts):
		m = bisearch_smallest(lambda A: 5 * A ** 4 - 5 * (A - num) ** 4 >= 0, 0, 10 ** 9)
		i = bisearch_smallest(lambda A: A ** 5 - (A - num) ** 5 <= X, 0, m + 1)
		j = bisearch_smallest(lambda A: A ** 5 - (A - num) ** 5 >= X, m - 1, 10 ** 9)
		
		if i ** 5 - (i - num) ** 5 == X:
			return i, i - num
		if j ** 5 - (j - num) ** 5 == X:
			return j, j - num
	else:
		f, c = facts[n]
		for i in range(c + 1):
			ret = find(num, n + 1)
			if ret != None:
				return ret
			num *= f
	return None

A, B = find(1, 0)


print(A, B)
### BUGGY CODE ###

N = int(input())
S = input()

R = []
G = []
B = []

for i in range(N):
    if S[i] == 'R':
        R.append(i+1)
    elif S[i] == 'G':
        G.append(i+1)
    elif S[i] == 'B':
        B.append(i+1)

cnt = 0
for r in R:
    for g in G:
        for b in B:
            temp = sorted([r, g, b])
            if (temp[2]-temp[1]) != (temp[1]-temp[0]):
                cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
S = input()

R = []
G = []
B = []

for i in range(N):
    if S[i] == 'R':
        R.append(i+1)
    elif S[i] == 'G':
        G.append(i+1)
    elif S[i] == 'B':
        B.append(i+1)

lenb = len(B)

cnt = 0
for r in R:
    for g in G:
        up = max(r, g)
        down = min(r, g)
        diff = up - down
        
        chk = 0
        if up + diff <= N:
            if S[up+diff-1] == 'B':
                chk += 1
        if down-diff >= 1:
            if S[down-diff-1] == 'B':
                chk += 1
        if diff%2 == 0:
            if S[int(up-diff/2-1)] == 'B':
                chk += 1
        cnt += lenb - chk

print(cnt)
### BUGGY CODE ###

N=int(input())
S=input()
ans=0
for i in range(N-1):
  #jstart=i+ans+1
  for j in range(i+1,N):
    if S[i:j] in S[j:]:
      ans=max(ans,j-i)
    else:
      break
print(ans)

### FIXED CODE ###

N=int(input())
S=input()
ans=0
for i in range(N-1):
  jstart=i+ans+1
  for j in range(jstart,N):
    if S[i:j] in S[j:]:
      ans=max(ans,j-i)
    else:
      break
print(ans)
### BUGGY CODE ###

from collections import* #defaultdict Counter deque appendleft
import sys
input=sys.stdin.readline

def main():
    n=int(input())
    d=[[]]+[deque(map(int,input().split()))for i in n*[0]]

    c=0
    while any(d):
        c+=1
        f=0
        skip=set()
        for i in range(1,n+1):
            if i not in skip:
                if d[i]:
                    if d[i][0] in skip:
                        continue
                    elif i==d[d[i][0]][0]:
                        oppo=d[i].popleft()
                        d[oppo].popleft()
                        skip.add(oppo)
                        skip.add(i)
                        f=1

        if not f:
            print(-1)
            exit()

    print(c)

if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import* #defaultdict Counter deque appendleft
import sys
input=sys.stdin.readline
import time
t=time.time()

def main():
    n=int(input())
    d=[[]]+[deque(map(int,input().split()))for i in n*[0]]

    c=0
    while any(d):
        c+=1
        f=0
        skip=set()
        for i in range(1,n+1):
            if i not in skip:
                if d[i]:
                    if d[i][0] in skip:
                        continue
                    elif i==d[d[i][0]][0]:
                        oppo=d[i].popleft()
                        d[oppo].popleft()
                        skip.add(oppo)
                        skip.add(i)
                        f=1

        if not f:
            print(-1)
            exit()
        if abs(time.time()-t)>1:
            print(n*(n-1)//2)
            exit()

    print(c)

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

nk = input().split()
n = int(nk[0])
k = int(nk[1])
a = list(map(int, input().split()))

p = []
for i in range(k - 1, n):
    p_i = 1
    for j in range(k):
        p_i *= a[i - j]
    p.append(p_i)

for i in range(len(p)):
    if i == 0:
        continue
    if p[i] > p[i - 1]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

nk = input().split()
n = int(nk[0])
k = int(nk[1])
a = list(map(int, input().split()))

for i in range(k, n):
    if a[i] > a[i - k]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

x, y, a, b, c = map(int, input().split())
Lista = sorted(list(map(int, input().split())), reverse = True)
Listb = sorted(list(map(int, input().split())), reverse = True)
Listc = sorted(list(map(int, input().split())), reverse = True)
if x < a:
    del Lista[x:a]
if y < b:
    del Listb[y:b]
List = sorted(Lista + Listb, reverse = True)
while len(Listc) > 0:
    if List[-1] < Listc[0]:
        List[-1] = Listc[0]
        List = sorted(List, reverse = True)
        del Listc[0]
    else:
        break
print(sum(List))

### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
Lista = sorted(list(map(int, input().split())), reverse = True)
Listb = sorted(list(map(int, input().split())), reverse = True)
Listc = sorted(list(map(int, input().split())), reverse = True)
if x < a:
    del Lista[x : a]
if y < b:
    del Listb[y : b]
List = sorted(Lista + Listb, reverse = True)
i = -1
for n in range(min(x + y, c)):
    if List[-n-1] < Listc[n]:
        i = n
    else:
        break
del List[x + y - i -1 : x + y]
del Listc[i + 1 : c]
print(sum(List) + sum(Listc))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    print(A.count(i))


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [0 for i in range(0,N)]
for i in range(0,len(A)):
    B[A[i]-1] += 1
for j in range(0,len(B)):
    print(B[j])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = list(map(int, input().split()))
mid = N // 2 - 1

for i in range(N):
    arr = X[:i]+X[i+1:]
    arr.sort()
    print(arr[mid])


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = list(map(int, input().split()))
X_sorted = sorted(X)
L = X_sorted[N//2-1]
R = X_sorted[N//2]


for x in X:
    print(L if x >= R else R)
### BUGGY CODE ###

X, K, D = map(int, input().split())

for k in range(K):
    if X >= 0:
        X = X - abs(D)
    else:
        X = X + abs(D)

print(abs(X))

### FIXED CODE ###

X, K, D = map(int, input().split())
X = abs(X)
D = abs(D)
if X > K * D:
    X = X - K*D
else:
    quo = X//D
    X = X - D*quo
    res = K - quo
    if res % 2 == 1:
        X = X - D
    else:
        pass

print(abs(X))
### BUGGY CODE ###

import sys
from collections import defaultdict

sys.setrecursionlimit(2147483647)


class Graph:
    def __init__(self):
        self.graph = defaultdict(set)

    def interconnect(self, u, v):
        self.graph[u].add(v)
        self.graph[v].add(u)

    def dfs(self, start):
        seen = set()
        return self.dfs_recurse(start, seen)

    def dfs_recurse(self, v, seen):
        seen.add(v)
        for u in self.graph[v] - seen:
            self.dfs_recurse(u, seen)
        return seen


if __name__ == "__main__":
    n, m, k = map(int, input().split())

    friends = Graph()
    blocked = defaultdict(set)

    [friends.interconnect(*map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    for _ in range(k):
        c, d = map(lambda x: int(x) - 1, input().split())
        blocked[c].add(d)
        blocked[d].add(c)

    visited = [False] * n
    counts = [0] * n

    for v in range(n):
        if visited[v]:
            continue
        elems = friends.dfs(v)
        elems_cnt = len(elems)
        for i in elems:
            counts[i] = elems_cnt - len(elems & friends.graph[i]) - len(elems & blocked[i]) - 1
            visited[i] = True

    print(*counts)


### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]


if __name__ == "__main__":
    n, m, k = map(int, input().split())

    u = UnionFind(n)
    f_cnt = [0] * n
    b_cnt = [0] * n

    for _ in range(m):
        a, b = map(int, input().split())
        u.union(a - 1, b - 1)
        f_cnt[a - 1] += 1
        f_cnt[b - 1] += 1

    for _ in range(k):
        c, d = map(int, input().split())
        if u.same(c - 1, d - 1):
            b_cnt[c - 1] += 1
            b_cnt[d - 1] += 1

    print(*[(u.size(i) - f_cnt[i] - b_cnt[i] - 1) for i in range(n)])
### BUGGY CODE ###

# modulo:mod

# inverse x^(-1)
def inv(x):
    global mod
    return pow(x,mod-2,mod)

# factorial x!
def fact(x):
    global mod
    res=1
    for i in range(2,x+1):
        res=res*i%mod
    return res

# combination nCr
def combi(n,r):
    if r<0 or r>n:
        return 0
    else:
        return fact(n)*inv(fact(r))*inv(fact(n-r))%mod

mod=10**9+7

N=int(input())
x=[0]
x.extend(list(map(int,input().split())))
invs=[inv(d) for d in range(N)]
# print(invs)
ans=0
for i in range(1,N):
    for j in range(i+1,N):
        temp=(x[j]-x[i])*invs[j-i]*invs[j-i+1]%mod
        ans=(ans+temp)%mod
    temp=(x[N]-x[i])*invs[N-i]%mod
    ans=(ans+temp)%mod
ans=ans*fact(N-1)%mod

print(ans)

### FIXED CODE ###

# modulo:mod

# inverse x^(-1)
def inv(x):
    global mod
    return pow(x,mod-2,mod)

# factorial x!
def fact(x):
    global mod
    res=1
    for i in range(2,x+1):
        res=res*i%mod
    return res

# combination nCr
def combi(n,r):
    if r<0 or r>n:
        return 0
    else:
        return fact(n)*inv(fact(r))*inv(fact(n-r))%mod

mod=10**9+7

N=int(input())
x=[0]
x.extend(list(map(int,input().split())))
invs=[inv(d) for d in range(N)]
# print(invs)
ans=0;s=0
for d in range(1,(N-1)//2+1):
    s=(s+x[N-d]-x[d])%mod
    ans=(ans+s*invs[d]*invs[d+1])%mod
    if d!=N-d-1:
        ans=(ans+s*invs[N-d-1]*invs[N-d])%mod
for i in range(1,N):
    ans=(ans+(x[N]-x[i])*invs[N-i])%mod
ans=ans*fact(N-1)%mod

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

def deque(n, arr):
    dp = [[0] * n for _ in range(n)]
    for i in range(n):
        dp[i][i] = arr[i]

    for l in range(n-2, -1, -1):
        for r in range(l+1, n):
            dp[l][r] = max(arr[l] - dp[l+1][r], arr[r] - dp[l][r-1])
    return dp[0][n-1]

n = int(input())
arr = [int(x) for x in input().split()]
print(deque(n, arr))


### FIXED CODE ###

def deque(n, arr):
    dp = [[0] * n for _ in range(n)]
    for i in range(n):
        dp[i][i] = arr[i]

    for l in range(n-2, -1, -1):
        for r in range(l+1, n):
            L = arr[l] - dp[l+1][r]
            R = arr[r] - dp[l][r-1]
            dp[l][r] = L if L > R else R
    return dp[0][n-1]

n = int(input())
arr = [int(x) for x in input().split()]
print(deque(n, arr))
### BUGGY CODE ###

import math

MOD = 10 ** 9 + 7

N, M = map(int, input().split())
a = [-1] + [int(input()) for i in range(M)] + [N + 1]

c = {}
def nCr(n, r):
    if (n, r) in c:
        return c[(n, r)]
    a = math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    c[(n, r)] = a
    return a

d = {}
def step(n):
    if n in d:
        return d[n]
    a = 0
    for k in range(n // 2 + 1):
        a += nCr(n - k, k)
    d[n] = a
    return a

ans = 1
for i in range(M + 1):
    n = a[i + 1] - a[i] - 2
    if n < 0:
        ans = 0
    else:
        ans *= step(n)
        ans %= MOD
print(ans)


### FIXED CODE ###

from collections import defaultdict

N, M = map(int, input().split())
a = defaultdict(lambda: True)
for i in range(M):
    a[int(input())] = False

dp = defaultdict(int)
dp[0] = 1
for i in range(1, N + 1):
    if a[i]:
        dp[i] = dp[i - 1] + dp[i - 2]
print(dp[N] % (10 ** 9 + 7))
### BUGGY CODE ###

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

for i in range(1,n+1):
    print(a.count(i))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
for i in range(1,n+1):
    print(c[i])
### BUGGY CODE ###

a, b, k = map(int, input().split())
numalllist = [num for num in range(a, b + 1)]
if k >= len(numalllist) :
    for i in numalllist :
        print(i)
else :
    small = numalllist[:k]
    large = sorted(numalllist, reverse=True)[:k]
    anslist = sorted(list(set(small + large)))
    for i in anslist :
        print(i)

### FIXED CODE ###

a, b, k = map(int, input().split())
if 2 * k >= b - a + 1 : 
    i = a
    while i <= b :
        print(i)
        i += 1
else :
    i = a
    while i <= a + k - 1 :
        print(i)
        i += 1
    i = b - k + 1
    while i <= b :
        print(i)
        i += 1
### BUGGY CODE ###

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

def light(a_list):
    outcome= [0]*n
    for i in range(n):
        for j in range(max(0,i-a_list[i]),min(n,i+a_list[i]+1)):
            outcome[j] += 1
    return outcome

for _ in range(k):
    if sum(a) >= n*n:
        break
    a = light(a)

[print(aa,end=' ') for aa in a]

### FIXED CODE ###

import numpy as np
from numba import njit

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

@njit(cache=True)
def light(n,a_list):
    outcome= np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if min(a) == n:
        break
    a = light(n,a)

[print(aa,end=' ') for aa in a]
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 5)

n, u, v = map(int, input().split())
u -= 1
v -= 1
es = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

def dfs(v, dist, p=-1, d=0):
    dist[v] = d
    for nv in es[v]:
        if nv == p:
            continue
        dfs(nv, dist, v, d+1)

def calc_dist(x):
    dist = [-1] * n
    dfs(x, dist)
    return dist

dist_t = calc_dist(u)
dist_a = calc_dist(v)

mx = 0
for i in range(n):
    if dist_t[i] < dist_a[i]:
        mx = max(mx, dist_a[i])

ans = mx - 1
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5)

n, u, v = map(int, input().split())
u -= 1
v -= 1
es = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

def dfs(v, dist, p=-1, d=0):
    dist[v] = d
    for nv in es[v]:
        if nv == p:
            continue
        dfs(nv, dist, v, d+1)

def calc_dist(x):
    dist = [-1] * n
    dfs(x, dist)
    return dist

dist_t = calc_dist(u)
dist_a = calc_dist(v)

mx = 0
for i in range(n):
    if dist_t[i] < dist_a[i]:
        mx = max(mx, dist_a[i])

ans = mx - 1
print(ans)