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

from collections import deque
from numba import njit, b1, i4, i8, f8
import numpy as np
import sys

read = sys.stdin.read
readline = sys.stdin.readline

@njit
def solve(H,W,C_h,C_w,D_h,D_w,S):
  INF = int(1e7)
  dist = [[0]*(W) for _ in range(H)]
  for i in range(H):
    for j in range(W):
      dist[i][j] = INF
  dist[C_h][C_w] = 0
  seen = [[False]*(W) for _ in range(H)]
  que1 = [(C_h,C_w)]
  que2 = []
  i,j = 0,0

  move_a = [(1,0),(0,1),(-1,0),(0,-1)]
  move_b = [(-2,-2),(-2,-1),(-2,0),(-2,1),(-2,2),(-1,-2),(-1,-1),(-1,1),(-1,2),(0,-2),(0,2),(1,-2),(1,-1),(1,1),(1,2),(2,-2),(2,-1),(2,0),(2,1),(2,2)]

  while True:
    if i==len(que1) and j==len(que2):
      break;
    while i<len(que1):
      h,w = que1[i]
      i += 1
      for dh,dw in move_a:
        nh,nw = h+dh,w+dw
        if 0<=nh<H and 0<=nw<W and S[nh][nw]!='#' and dist[nh][nw] > dist[h][w]:
          dist[nh][nw] = dist[h][w]
          que1.append((nh,nw))
      for dh,dw in move_b:
        nh,nw = h+dh,w+dw
        if 0<=nh<H and 0<=nw<W and S[nh][nw]!='#' and dist[nh][nw] > dist[h][w]+1:
          dist[nh][nw] = dist[h][w]+1
          que2.append((nh,nw))
    while j<len(que2):
      h,w = que2[j]
      j += 1
      for dh,dw in move_a:
        nh,nw = h+dh,w+dw
        if 0<=nh<H and 0<=nw<W and S[nh][nw]!='#' and dist[nh][nw] > dist[h][w]:
          dist[nh][nw] = dist[h][w]
          que1.append((nh,nw))
      for dh,dw in move_b:
        nh,nw = h+dh,w+dw
        if 0<=nh<H and 0<=nw<W and S[nh][nw]!='#' and dist[nh][nw] > dist[h][w]+1:
          dist[nh][nw] = dist[h][w]+1
          que2.append((nh,nw))
  print(dist[D_h][D_w] if dist[D_h][D_w]<INF else -1)

H,W = map(int,readline().split())
C_h,C_w = map(lambda x:int(x)-1,readline().split())
D_h,D_w = map(lambda x:int(x)-1,readline().split())
S = np.array([readline() for _ in range(H)])
solve(H,W,C_h,C_w,D_h,D_w,S)

### FIXED CODE ###

from collections import deque

H,W = map(int,input().split())
C_h,C_w = map(lambda x:int(x)-1,input().split())
D_h,D_w = map(lambda x:int(x)-1,input().split())
S = [input() for _ in range(H)]

INF = int(1e10)
dist = [[INF]*(W) for _ in range(H)]
deq = deque()
deq.append((C_h,C_w,0))

move_a = [(1,0),(0,1),(-1,0),(0,-1)]
move_b = [(i,j)for i in range(-2,2+1) for j in range(-2,2+1) if abs(i)+abs(j)>=2]

while len(deq):
  h,w,c = deq.popleft()
  if dist[h][w] <= c:
    continue
  dist[h][w] = c
  for dh,dw in move_a:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c:
      deq.appendleft((nh,nw,c))
  for dh,dw in move_b:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c+1:
      deq.append((nh,nw,c+1))
  
print(dist[D_h][D_w] if dist[D_h][D_w]<INF else -1)
### BUGGY CODE ###

from math import factorial

N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7


# 2回表れている値とそのインデックスを取得
for a in A:
    if A.count(a) == 2:
        C = a
C_indexes = [i for i, x in enumerate(A) if x == C]

# 二つのCの外側にそれぞれ何個ずつあるか
outside = C_indexes[0] + len(A) - C_indexes[1] - 1

X = factorial(N+1)
O = factorial(outside) % MOD

L = list(range(1, N+2))
l1 = 1
l2 = X

X %= MOD

for k in range(1, len(A)+1):
    l1 *= k
    l2 //= L[-k]
    if k > outside + 1:
        Y = pow((l1 * l2) % MOD, MOD-2, MOD)
        print((X * Y) % MOD)
    else:
        Y = pow(l1 * l2 % MOD, MOD - 2, MOD)
        Y2 = pow((factorial(k-1)) * factorial(outside - k + 1) % MOD, MOD - 2, MOD)
        print(((X * Y) % MOD - (O * Y2) % MOD))


### FIXED CODE ###

from statistics import mode

N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

# 2回表れている値とそのインデックスを取得
C = mode(A)
C_indexes = [i for i, x in enumerate(A) if x == C]

# 二つのCの外側にそれぞれ何個ずつあるか
outside = C_indexes[0] + len(A) - C_indexes[1] - 1

# 階乗・逆元の値を保存
factorial = [1]
inverse = [1]
for i in range(1, N+2):
    factorial.append(factorial[-1]*i % MOD)
    inverse.append((pow(factorial[i], MOD-2, MOD)))

# combination計算
def nCr(n, r):
    if n<r or n==0 or r==0:
        return 0
    return factorial[n] * inverse[r] * inverse[n-r] % MOD


print(N)
for i in range(2, N+2):
    print(int(nCr(N+1, i) - nCr(outside, i-1)) % MOD)
### BUGGY CODE ###

s = list(input().strip())
q = int(input().strip())
queries = []
one_count = 0
one_counts = []
for i in range(q):
    inp = input().split()
    queries.append(inp)
    if inp[0] == "1":
        one_count += 1
    one_counts.append(one_count)
one_counts = list(map(lambda x: (one_count - x), one_counts))
if one_count % 2 == 1:
    s = s[::-1]
for i in range(q):
    if queries[i][0] == "1":
        continue
    elif queries[i][0] == "2":
        if queries[i][1] == "1":
            if one_counts[i] % 2 == 0:
                s.insert(0, queries[i][2])
            else:
                s.append(queries[i][2])
        elif queries[i][1] == "2":
            if one_counts[i] % 2 == 0:
                s.append(queries[i][2])
            else:
                s.insert(0, queries[i][2])
print("".join(s))


### FIXED CODE ###

s = list(input().strip())
q = int(input().strip())
queries = []
one_count = 0
one_counts = []
for i in range(q):
    inp = input().split()
    queries.append(inp)
    if inp[0] == "1":
        one_count += 1
    one_counts.append(one_count)
one_counts = list(map(lambda x: (one_count - x), one_counts))
if one_count % 2 == 1:
    s = s[::-1]
pre = []
suf = []
for i in range(q):
    if queries[i][0] == "1":
        continue
    elif queries[i][0] == "2":
        if queries[i][1] == "1":
            if one_counts[i] % 2 == 0:
                pre.append(queries[i][2])
            else:
                suf.append(queries[i][2])
        elif queries[i][1] == "2":
            if one_counts[i] % 2 == 0:
                suf.append(queries[i][2])
            else:
                pre.append(queries[i][2])
print("".join(pre[::-1] + s + suf))
### BUGGY CODE ###

import math
import numpy as np

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

# lstA.sort()
# lstF.sort()
# lstF.reverse()
lstA = np.sort(lstA)
lstF = np.sort(lstF)[::-1]

def check(x):
    checker = 0
    for i in range(n):
        checker += math.ceil(lstA[i]-x/lstF[i])
    if checker <= k:
        return True
    else:
        return False

left = -1
right = 10**12

while left <= right:
    center = (left+right)//2
    if check(center) == True:
        right = center
    else:
        left = center
    if right <= left+1:
        print(right)
        exit()


### FIXED CODE ###

import numpy as np

n,k = map(int, input().split())
lstA = np.array(sorted(list(map(int, input().split()))))
lstF = np.array(sorted(list(map(int, input().split())), reverse=True))
s = lstA.sum()

left = -1
right = 10**12

while True:
    center = (left+right)//2
    if s-np.minimum(lstA, center//lstF).sum() <=k:
        right = center
    else:
        left = center
    if right <= left+1:
        print(right)
        exit()
### BUGGY CODE ###

n, x, y = map(int, input().split())


arr = [[10**4] * n for i in range(n)]
for i in range(n-1):
        arr[i][i+1] = 1
        arr[i+1][i] = 1
arr[x-1][y-1] = 1
arr[y-1][x-1] = 1

import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

csr = csr_matrix(arr)
dist_m = shortest_path(csr, directed=False)

ans = [0] * (n-1)
for i in range(n):
    dist = dist_m[i].tolist()
    for j in range(len(dist)):
        ans[int(dist[j])] += 1

for i in range(1,len(ans)):
    print(ans[i] // 2)
print(0)


### FIXED CODE ###

n, x, y = map(int, input().split())


min_dist = [0] * n

for i in range(n):
    for j in range(i+1,n):
        dist = min(abs(j-i), abs(j-(y-1)) + 1 +abs((x-1)-i))
        min_dist[dist] += 1

for i in range(1,n):
    print(min_dist[i])
### BUGGY CODE ###

n = int(input())
data_list = [input() for i in range(n)]
data_list.sort()


data_set = set(data_list)
sorted_list = sorted(data_set)

count_list = [0] * len(sorted_list)

for i in range(len(sorted_list)):
    count_list[i] = data_list.count(sorted_list[i])

max_indexes = [i for i, x in enumerate(count_list) if x == max(count_list)]

for i in range(len(max_indexes)):
    print(sorted_list[max_indexes[i]])

### FIXED CODE ###

import collections

n = int(input())
data_list = [input() for i in range(n)]
data_list.sort()

count_dict = collections.Counter(data_list)

max_val = max(count_dict.values())
max_keys = [key for key in count_dict if count_dict[key] == max_val]

max_keys.sort()

for i in range(len(max_keys)):
    print(max_keys[i])
### BUGGY CODE ###

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

heapq.heapify(a)
for i in range(m):
    b, c = list(map(int, input().split()))

    for j in range(b):
        if c > a[0]:
            heapq.heapreplace(a, c)
        else:
            break

print(sum(a))

### FIXED CODE ###

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

cnt = {}

for i in range(n):
    if a[i] in cnt:
        cnt[a[i]] += 1
    else:
        cnt[a[i]] = 1

for i in range(m):
    b, c = list(map(int, input().split()))

    if c in cnt:
        cnt[c] += b
    else:
        cnt[c] = b

cnts = sorted(cnt.items())
cnt = 0
tot = 0
last = (0, 0)

while cnt < n:
    last = cnts.pop()
    tot += last[0] * last[1]
    cnt += last[1]

tot -= (cnt-n)*last[0]
print(tot)
### BUGGY CODE ###

a = 0
n = int(input())
while n != 0:
  a += n % 10
  n = n // 10 

b = 0
while a != 0:
  b += a % 10
  a = a // 10 

c = 0
while b != 0:
  c += b % 10
  b = b // 10 

d = 0
while c != 0:
  d += c % 10
  c = c // 10 


if d % 9 == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a = 0
s = input()
for c in s:
  a += int(c)

if a % 9 == 0:
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

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

def main():
    ans = float('inf')
    for i in range(N - 1):
        A[i] *= -1
        ans = min(ans, abs(sum(A)))
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

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

def main():
    sum_n = sum(A)
    mid = sum_n / 2
    a = 0
    abs_list = []
    for i in range(N - 1):
        a += A[i]
        abs_list.append((abs(mid - a), i))    
    abs_list.sort()
    idx = abs_list[0][1]

    left = sum(A[:idx + 1])
    right = sum(A[idx + 1:])
    print(abs(left - right))

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

#!/usr/bin/env/ python3
N = int(input())
S = input()
#A, B, C = input().split()
#A, B, C, X, Y = map(int, input().split())

#N = int(input())
#H, W = map(int, input().split())
#S = [input() for _ in range(H)]
#print(A[0][0])

ans = 0
for tmp_num in range(1000):
    tmp = str(tmp_num).zfill(3)
    digit = 0
    for i in range(N):
        if S[i] == tmp[digit]:
            digit += 1
            if digit == 3:
                ans += 1
                break
print(ans)


### FIXED CODE ###

#!/usr/bin/env/ python3
N = int(input())
S = input()
#A, B, C = input().split()
#A, B, C, X, Y = map(int, input().split())

#N = int(input())
#H, W = map(int, input().split())
#S = [input() for _ in range(H)]
#print(A[0][0])

ans = 0
for tmp_num in range(1000):
    tmp = str(tmp_num).zfill(3)
    digit = 0
    for i in range(N):
        if S[i] == tmp[digit]:
            digit += 1
            if digit == 3:
                ans += 1
                break
print(ans)
### BUGGY CODE ###

from fractions import gcd

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

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

div = 10**9 + 7
lcm_num = lcm(a)
ans = [(lcm_num // ai) % div for ai in a]

print(sum(ans)%div)

### FIXED CODE ###

from fractions import gcd

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

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

div = 10**9 + 7
lcm_num = lcm(a)
ans = [lcm_num//ai for ai in a]

print(sum(ans)%div)
### BUGGY CODE ###

n = int(input())
x = map(int, input().split())
x = list(x)
for c in x:
    x_remove = x.copy()
    x_remove.remove(c)
    x_remove.insert(0,0)
    x_remove.append(0)
    i = 0
    ans = 0
    while i < len(x_remove)-1:
        ans += abs(x_remove[i+1] - x_remove[i])        
        i += 1
    print(ans)

### FIXED CODE ###

n = int(input())
X = map(int, input().split())
X = list(X)
# n = 3
# X = [3, 5, -1]

X.insert(0,0)
X.append(0)
Y = []
for i, x in enumerate(X[1:]):
    Y.append(abs(x-X[i]))
sumY = sum(Y)

for i, x in enumerate(X):
    if i not in [0,len(X)-1]:
        ans = sumY - (Y[i-1] + Y[i]) + abs(X[i+1]-X[i-1])
        print(ans)
### BUGGY CODE ###

from bisect import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans = 0
b_c= [0]*n
for i  in range(n-2):
    a = l[i]
    pre_k = 2
    for j in range(i+1,n-1):
        b = l[j]
        max_c = a+b-1
        k = bisect(l[j+pre_k-1:],max_c)
        ans += (pre_k-2 + k)
print(ans)

### FIXED CODE ###

from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans = 0
for i  in range(n-2):
    a = l[i]
    for j in range(i+1,n-1):
        b = l[j]
        k = bisect_left(l,a+b)
        ans += k-j-1
print(ans)
### BUGGY CODE ###

import math
import fractions
import functools
def main():
    n = int(input())
    a = [int(t)for t in input().split()]

    M = 10**9+7
    culcm = functools.reduce(lcm,a)

    b = [culcm//a_i for a_i in a]

    print(sum(b)%M)

def lcm(a,b):
    return a*b//fractions.gcd(a,b)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import math
import fractions
import functools
def main():
    n = int(input())
    a = [int(t)for t in input().split()]

    M = 10**9+7
    culcm = functools.reduce(lcm,a)

    b = [culcm//a_i for a_i in a]

    print(sum(b)%M)

def lcm(a,b):
    return a*b//fractions.gcd(a,b)

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

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

move=[]
for i in range(0,N):
    move.append([])
    A[i]-=1
    move[i].append(A[i])


for j in range(1,64):
    for i in range(0,N):
        move[i].append(move[move[i][j-1]][j-1])
town=0
for i in range(0,64):
    if K%2==1:
        town=move[town][i]
    K//=2

print(town+1)


### FIXED CODE ###

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

move=[]
for i in range(0,N):
    move.append([])
    A[i]-=1
    move[i].append(A[i])


for j in range(1,64):
    for i in range(0,N):
        move[i].append(move[move[i][j-1]][j-1])
town=0
for i in range(0,64):
    if K%2==1:
        town=move[town][i]
    K//=2

print(town+1)
### BUGGY CODE ###

n,k = map(int,input().split())
i=0
x=1
while i < x:
  if n > abs(n-k):
    n = abs(n-k)
    x=x+1
  else:
    break  
  i=i+1
print(n)

### FIXED CODE ###

n,k = map(int,input().split())
s = n%k
t= abs(s-k)
if s<t:
  print(s)
else:
  print(t)
### BUGGY CODE ###

N, K = map(int,input().split())
if K == 1 or N == 0:
    print(0)
    exit()
elif K == 0:
    print(N)
    exit()
elif N == 1:
    print(1)
    exit()
else:
    l = []
    ans = N
    for i in range(max(N,K)):
        ans = abs(ans - K)
        l.append(ans)
    print(min(l))

### FIXED CODE ###

N, K = map(int,input().split())
if K == 1 or N == 0 or N == K or N%K==0:
    print(0)
elif K == 0:
    print(N)
elif N == 1 or N == K-1 or K == N-1 or N%K==1:
    print(1)
elif N > K:
    res = abs(N - (K*(N//K)))
    if abs(res - K) < res:
        print(abs(res-K))
    else:
        print(res)
elif K > N:
    if abs(K-N) < N:
        print(abs(K-N))
    else:
        print(N)
### BUGGY CODE ###

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

S = int()

for i in range(A):
    S = S + 1
    K = K - 1
    if K == 0:
        break

for i in range(B):
    if K == 0:
        break
    K = K -1

for i in range(C):
    if K == 0:
        break
    S = S - 1
    K = K - 1

print(S)

### FIXED CODE ###

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

S = int()

if K >= A:
    S = S + A
    K = K - A

    if K >= B:
        K = K - B

        if K > 0:
            S = S - K
            print(S)
        else:
            print(S)

    else:
        print(S)

else:
    S = S + K
    print(S)
### BUGGY CODE ###

k, s = input().split()
k, s = int(k), int(s)
ans = 0
for x in range(0, k+1):
  for y in range(0, k+1):
    for z in range(0, k+1):
      if x+y+z==s:
        ans += 1
        continue
print(ans)

### FIXED CODE ###

k, s = input().split()
k, s = int(k), int(s)
ans = 0
for x in range(0, k+1):
  for y in range(0, k+1):
      if -1<s-x-y<k+1:
        ans += 1
print(ans)
### BUGGY CODE ###

import numpy as np

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

ans = []
for i in range(n):
  tmpidx = np.argmin(A)
  A[tmpidx] = np.inf
  ans.append(tmpidx+1)

print(*ans)

### FIXED CODE ###

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

ans = [0 for _ in range(n)]
for i in range(n):
  ans[A[i]-1] = i+1

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

def DP(A,N,S,M):
    dp = [[0 for _ in range(S+1)] for _ in range(N+1)]
    dp[0][0] = 1
    #dp[i][j]:要素数i個以下,i番目までで和がjである部分集合の個数
    for i in range(1,N+1):
        for j in range(S+1):
            dp[i][j] = 2 * dp[i-1][j]
            dp[i][j] %= M
            if j - A[i-1] >= 0:
                dp[i][j] += dp[i-1][j-A[i-1]]
                dp[i][j] %= M

    return dp[N][S]

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

    ans = DP(A,N,S,M)
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def DP(A,N,S,M):
    dp = [[0 for _ in range(S+1)] for _ in range(N+1)]
    dp[0][0] = 1
    #dp[i][j]:要素数i個以下,i番目までで和がjである部分集合の個数
    for i in range(1,N+1):
        for j in range(S+1):
            dp[i][j] = 2 * dp[i-1][j]
            dp[i][j] %= M
            if j - A[i-1] >= 0:
                dp[i][j] += dp[i-1][j-A[i-1]]
                dp[i][j] %= M

    return dp[N][S]

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

    ans = DP(A,N,S,M)
    print(ans)

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

#! /usr/bin/env python3

n, m, qq = map(int, input().split())

lr = [[0 for i in range(n + 1)] for j in range(n + 1)]

for _ in range(m):
    l, r = map(int, input().split())
    lr[l][r] += 1

for i in range(1, n + 1):
    for j in range(1, n + 1):
        lr[i][j] += lr[i][j-1]

res = []
for _ in range(qq):
    ans = 0
    p, q = map(int, input().split())
    for i in range(p, q + 1):
        ans += lr[i][q] - lr[i][i - 1]
    res.append(ans)

for row in res:
    print(row)


### FIXED CODE ###

#! /usr/bin/env python3

n, m, qq = map(int, input().split())

lr = [[0 for i in range(n + 1)] for j in range(n + 1)]
acc = [[0 for i in range(n + 1)] for j in range(n + 1)]

for _ in range(m):
    l, r = map(int, input().split())
    lr[l][r] += 1

for i in range(1, n + 1):
    for j in range(1, n + 1):
        acc[i][j] = acc[i][j-1] + lr[i][j]

res = []
for _ in range(qq):
    ans = 0
    p, q = map(int, input().split())
    for i in range(p, q + 1):
        ans += acc[i][q] - acc[i][i - 1]
    res.append(ans)

for row in res:
    print(row)
### BUGGY CODE ###

N,Q = map(int, input().split(' '))
S = input()
lr = [list(map(int,input().split(' '))) for i in [0]*Q]

cnts = [S[:i].count("AC") for i in range(1,N+1)]

for l,r in lr:
	print(cnts[r-1]-cnts[l-1])




### FIXED CODE ###

N,Q = map(int, input().split(' '))
S = input()
lr = [list(map(int,input().split(' '))) for i in [0]*Q]

#cnts = [S[:i].count("AC") for i in range(1,N+1)]
cnts = [0]*N

for i in range(1,N):
	if S[i-1:i+1] == "AC":
		cnts[i] = cnts[i-1]+1
	else:
		cnts[i] = cnts[i-1]



for l,r in lr:
	print(cnts[r-1]-cnts[l-1])
### BUGGY CODE ###

def process(a):
    tmp = a[0]
    pushed = []
    cnt = 1
    while not tmp in pushed:
        if tmp == 2:
            return cnt
        pushed.append(tmp)
        tmp = a[tmp - 1]
        cnt += 1
    return -1

if __name__ == '__main__':
    a = [int(input().strip()) for _ in range(int(input().strip()))]
    print(process(a))

### FIXED CODE ###

def process(a):
    tmp = a[0]
    pushed = set()
    cnt = 1
    while not tmp in pushed:
        if tmp == 2:
            return cnt
        pushed.add(tmp)
        tmp = a[tmp - 1]
        cnt += 1
    return -1

if __name__ == '__main__':
    a = [int(input().strip()) for _ in range(int(input().strip()))]
    print(process(a))
### BUGGY CODE ###

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

tmp = A[0]
while True:
    if(len(A) == 1):
        break
    for i in range(len(A)-1,0,-1):
        A[i] = A[i] - (A[i]//tmp)*tmp
        if 0 in A:
            A.remove(0)
    else:
        A.sort()
        tmp = A[0]
print(A[0])

### FIXED CODE ###

from fractions import gcd
from functools import reduce

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

print(reduce(gcd,A))
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
cnt = 0

for r in range(N//R+1):
	for g in range((N-R*r)//G+1):
		b = (N - R * r - G * g) / B
		if b.is_integer() and b >= 0:
			cnt += 1
print(cnt)


### FIXED CODE ###

R, G, B, N = map(int, input().split())
cnt = 0

for r in range(N//R+1):
	for g in range((N-R*r)//G+1):
		if (N - R * r - G * g) % B == 0:
			cnt += 1
print(cnt)
### BUGGY CODE ###

from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

MOD = 10**9 + 7
 
N = read()
A = reads()

fact = [1] * N
for i in range(1, N):
  fact[i] = (fact[i-1] * i) % MOD 
invfact = [0] * N; invfact[-1] = pow(fact[-1], MOD-2, MOD)
for i in range(N-2, -1, -1):
  invfact[i] = invfact[i+1] * (i+1)
def comb(n, k):
  # print(n, k)
  return fact[n] * invfact[n-k] * invfact[k] % MOD  

cnt = Counter(A)
q = next(i for i in range(1,N+1) if cnt[i] == 2)
i1 = A.index(q); i2 = A.index(q, i1+1)
m = N - (i2 - i1)
# print(m)

print(N)
for k in range(2, N+1):
  ans = comb(N-1, k-1) * 2 + comb(N-1, k-2)
  if m >= k-1:
    ans -= comb(m, k-1)
  if k <= N-1:
    ans += comb(N-1, k)
  print(ans % MOD)
print(1)

### FIXED CODE ###

from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

MOD = 10**9 + 7
 
N = read()
A = reads()

fact = [1] * N
for i in range(1, N):
  fact[i] = (fact[i-1] * i) % MOD 
invfact = [0] * N; invfact[-1] = pow(fact[-1], MOD-2, MOD)
for i in range(N-2, -1, -1):
  invfact[i] = invfact[i+1] * (i+1) % MOD
def comb(n, k):
  return fact[n] * invfact[n-k] * invfact[k] % MOD  

cnt = Counter(A)
q = next(i for i in range(1,N+1) if cnt[i] == 2)
i1 = A.index(q); i2 = A.index(q, i1+1)
m = N - (i2 - i1)
# print(m)

print(N)
for k in range(2, N+1):
  ans = comb(N-1, k-1) * 2 + comb(N-1, k-2)
  if m >= k-1:
    ans -= comb(m, k-1)
  if k <= N-1:
    ans += comb(N-1, k)
  print(ans % MOD)
print(1)
### BUGGY CODE ###

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

cou = [0]*n

for x in range(n):
    for k in range(n):
        if m[x] == m[k] or m[x] == m[k] -1 or m[x] == m[k] +1:
            cou[x] += 1

print(max(cou))

### FIXED CODE ###

import collections

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

zen = m
cou = 0

for x in range(n):
    zen.append(m[x]-1)

for x in range(n):
    zen.append(m[x]+1)

a = collections.Counter(zen)

#for k in range(n):
#    if a.most_common()[0][0] == m[k] or a.most_common()[0][0] == m[k] -1 or a.most_common()[0][0] == m[k] +1:
#        cou += 1

print(a.most_common()[0][1])