Harryxun/stf_run huggingface dataset:
N, K = map(int, input().split())
A = list(map(int, input().split()))

stack = [0]
def dfs(a, k):
    global stack
    if k == 0:
        return a
    if k == -1:
        return stack[-1]
    next_a = A[a]-1
    if next_a in stack:
        idx = stack.index(next_a)
        n = len(stack)
        k %= (n - idx)
        res = dfs(next_a, k - 1)
    else:
        stack.append(next_a)
        res = dfs(next_a, k-1)
    return res

print(dfs(0, K) + 1)

### FIXED CODE ###

N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

d = {1:0}
pre_a = 0
a = 1
c = 0
while K:
    K -= 1
    next_a = A[a]
    c += 1
    if next_a in d:
        idx = d[next_a]
        n = len(d)
        K %= (n - idx)
        K += 1
        break
    else:
        d[next_a] = c
        pre_a = a
        a = next_a

while K:
    pre_a = a
    a = A[a]
    K -= 1

print(a)
a,b=map(int,input().split())
for i in range(2,21):
	if b<= a*i-(i+1):
		print(i)
        break

### FIXED CODE ###

a,b=map(int,input().split())
for i in range(21):
	if b<= a*i-(i-1):
		print(i)
		break
a = int(input())
b = int(input())
n = [1, 2, 3].remove(a).remove(b)
print(n[0])

### FIXED CODE ###

a = int(input())
b = int(input())
c = 6 - a - b
print(c)
N = int(input())
E = []
for n in range(N):
    A = int(input())
    for _ in range(A):
        x, y = list(map(int, input().split()))
        E.append((n, x - 1, y))
ans = 0
for k in range((1 << N)):
    status = [(k >> i) & 1 for i in range(N)]
    no_paradox = True
    for Xa, Xb, yb in E:
        if (status[Xa] == 1 and status[Xb] == yb):
            no_paradox = False
            break
    if no_paradox:
        ans = max(ans, sum(l))

### FIXED CODE ###

N = int(input())
E = []
for n in range(N):
    A = int(input())
    for _ in range(A):
        x, y = list(map(int, input().split()))
        E.append((n, x - 1, y))
ans = 0
for k in range((1 << N) - 1, -1, -1):
    status = [(k >> i) & 1 for i in range(N)]
    no_paradox = True
    for Xa, Xb, yb in E:
        if (status[Xa] == 1 and status[Xb] != yb):
            no_paradox = False
            break
    if no_paradox:
        ans = max(ans, sum(status))
print(ans)
from collections import Counter
N = list(input())
M = [0]
S = 0
K = 1
ans = 0

for i in range(len(N)):
    S += int(N[-i-1])*K
    S %= 2019

    K *= 10
    K %= 2019
    M.append(S)

P = Counter(M)
for i in range(2020):ans+=P[i]*(P[i]-1)//2
print(ans)


### FIXED CODE ###

a,b = map(int,input().split())

if b-a>=0:
    print('unsafe')
else:
    print('safe')
if __name__ == '__main__':
  str = input()
  strList = [c for c in str]
  strList.append('e')
  strLength = len(strList)
  rLength = 0
  lLength = 0
  i = 0
  changePoint = 0

  child = [0 for i in range(strLength)]

  c = 'R'
  
  while(c != 'e'):
    c = strList[i]
    while(c == 'R'):
      i += 1
      c = strList[i]
      rLength += 1
    
    changePoint = i
    
    while(c == 'L'):
      i += 1
      c = strList[i]
      lLength += 1

    rRight = rLength/2
    rLeft = rLength - rRight

    lLeft = lLength/2
    lRight = lLength - lLeft

    child[changePoint-1] += rLeft + lLeft
    child[changePoint-1] += rRight + lRight
  
  for numOfChild in child:
    print(str(numOfChild) + ' ')

### FIXED CODE ###

if __name__ == '__main__':
  str = input()
  strList = [c for c in str]
  strList.append('e')
  strLength = len(strList)
  rLength = 0
  lLength = 0
  i = 0
  changePoint = 0

  child = [0 for i in range(strLength-1)]

  c = 'R'
  
  while(c != 'e'):
    c = strList[i]
    while(c == 'R'):
      i += 1
      c = strList[i]
      rLength += 1
    
    changePoint = i
    
    while(c == 'L'):
      i += 1
      c = strList[i]
      lLength += 1

    rRight = int(rLength/2)
    rLeft = rLength - rRight

    lLeft = int(lLength/2)
    lRight = lLength - lLeft

    child[changePoint-1] += rLeft + lLeft
    child[changePoint] += rRight + lRight

    rLength = 0
    lLength = 0
  
  for numOfChild in child:
    print(numOfChild, end="")
    print(' ', end="")
n,m=map(int,input().split())
x=list(map(int,input().split()))
count=0
a=max(x)
i=min(x)
if m<=2:
  print(count)
else:
  while True:
    x.remove(a)
    x.remove(b)
    a-=1
    b+=1
    count+=1
    if x==[]:
      print(count)
      break


### FIXED CODE ###

n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
y=[]
for i in range(len(x)-1):
  y+=[x[i+1]-x[i]]
y.sort()
if n>=m:
  print(0)
else:
  print(sum(y[:m-n]))
a,b=map(int,input().split())
if max(a,b)>9:
  print('-1')
else:
  print(a＊b)

### FIXED CODE ###

a,b=map(int,input().split())
if max(a,b)>9:
  print('-1')
else:
  print(a*b)
def main():
    from sys import stdin
    input = stdin.readline
    import numpy as np
    h, w, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    ab_d = {(a, b) for a, b in ab}

    ans = [set() for _ in range(9)]
    for a, b in ab:
        temp = np.full((5, 5), None)
        for i in range(max(0, 3-a), min(5, h-a+3)):
            for j in range(max(0, 3-b), min(5, w-b+3)):
                if (a+i-2, b+j-2) in ab_d:
                    temp[i, j] = 1
                else:
                    temp[i, j] = 0
        flag_yoko = [0, 5]
        flag_tate = [0, 5]
        if np.all(temp[:, 0] == np.full((1, 5), None)):
            if np.all(temp[:, 1] == np.full((1, 5), None)):
                flag_yoko[0] = 2
            else:
                flag_yoko[0] = 1
        if np.all(temp[:, 4] == np.full((1, 5), None)):
            if np.all(temp[:, 3] == np.full((1, 5), None)):
                flag_yoko[1] = 3
            else:
                flag_yoko[1] = 4
        if np.all(temp[0, :] == np.full(5, None)):
            if np.all(temp[1, :] == np.full(5, None)):
                flag_tate[0] = 2
            else:
                flag_tate[0] = 1
        if np.all(temp[4, :] == np.full(5, None)):
            if np.all(temp[3, :] == np.full(5, None)):
                flag_tate[1] = 3
            else:
                flag_tate[1] = 4
        new_temp = temp[flag_tate[0]:flag_tate[1], flag_yoko[0]:flag_yoko[1]]
        for i in range(flag_tate[1]-flag_tate[0]-2):
            for j in range(flag_yoko[1]-flag_yoko[0]-2):
                cnt = [new_temp[i+k, j+l] for k in range(3) for l in range(3)]
                if None not in cnt:
                    ans[sum(cnt)-1].add((a+i-2+flag_tate[0], b+j-2+flag_yoko[0]))

    for i in range(9):
        ans[i] = len(ans[i])

    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)


main()


### FIXED CODE ###

h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab_d={a*(10**9)+b-1 for a,b in ab}

ans=[set() for _ in range(9)]
for a,b in ab:
    temp=[None for _ in [0]*25]
    for i in range(5):
        for j in range(5):
            if 0<a+i-2<=h and 0<b+j-2<=w:
                if (a+i-2)*(10**9)+b+j-3 in ab_d:
                    temp[i*5+j]=1
                else:
                    temp[i*5+j]=0
    for i in range(3):
        for j in range(3):
            cnt=[temp[(i+k)*5+j+l] for k in range(3) for l in range(3)]
            if None not in cnt:
                ans[sum(cnt)-1].add((a+i-2)*(10**9)+b+j-3)
                
for i in range(9):
    ans[i]=len(ans[i])

print((h-2)*(w-2)-sum(ans))
for i in ans:
    print(i)
def main():
    s = list(input())
    k = input()
    n = len(s)
    for i in range(n):
        if s[i] != "1":
            ans = s[i]
            break
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    s = list(input())
    k = int(input())
    n = len(s)
    for i in range(n):
        if s[i] != "1":
            ans = s[i]
            break
        if i == k-1:
            ans = s[i]
            break
        if i == n-1:
            ans = s[0]
    print(ans)


if __name__ == "__main__":
    main()
A,B,C = map(int, input().split())
print('Yes') if A+B/C*2 == 1 print('No')

### FIXED CODE ###

A,B,C = map(int, input().split())
print('Yes') if A+B>C and C+B>A and A+C>B and A==B and B==C else print('No')
import math
A,B=map(int,input().split())
gcd_list=[]
so_list=[]
for num in range(1,math.gcd(A,B)+1):
    if A%num==0 and B%num==0:
        gcd_list.append(num)
for i in gcd_list:
    flag=0
    if len(so_list)==0:
        so_list.append(i)
    else:
        for num in so_list:
            if num==1:
                continue
            if i%num==0:
                flag=1
                break
        if flag==0:
            so_list.append(i)
print(len(so_list))


### FIXED CODE ###

from math import gcd
A, B = map(int,input().split())
max_cmn_div = gcd(A, B)

# 約数列挙関数
def make_divisor(n):
    divisor = []
    for i in range(1, int(n**(1/2))+1):
        if n % i == 0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
    return divisor

def check_prime(n):
    for i in range(2, int(n**(1/2))+1):
        if n % i == 0:
            return 0
    return 1

cmn_div = make_divisor(max_cmn_div)
ans = 0
for i in cmn_div:
    if check_prime(i):
        ans += 1
print(ans)
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
for i in range(X):
    for j in range(Y):
        if i + 1 + j + 1 > K:
            break
        for k in range(Z):
            if i + 1 + j + 1 + k + 1 > K:
                break
            ABC.append(A[i] + B[j] + C[k])

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])


### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            ABC.append(A[i] + B[j] + C[k])

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])
N = int(input()) - 1
array = list(map(int, input().split()))

breaktime = 0
i = 0
while i <= N:
  for j in range(N+1):
    if array[j] == i+1:
      del array[i:j]
      N = N - (j - i)
      breaktime += j-i
      break
    if j==N and array[j] != i+1:
      if i == 0:
        breaktime = -1
      else:
        del array[i:]
        breaktime += N-i+1
        break
  if breaktime == -1:
    break
  i += 1

print(breaktime)


### FIXED CODE ###

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

bt = 0 #break times
i = 0  
j = 0  #iterator

while i < n:
  while j < n:
    if array[j] == i+1:
      bt += 1
      break
      
    else:
      if j == n-1:
        if i == 0:
          bt = -1
          i = n+1
          j = n+1
          break
        else:
          i = n+1
          j = n+1
          break
          
    j += 1
  i +=1
  
if bt != -1:
  bt = n - bt
  
print(bt)
HW = raw_input().split()
hw = raw_input().split()

print HW[0] * HW[1] - hw[0] * HW[1] - hw[1] * HW[0] + hw[0] * hw[1]


### FIXED CODE ###

HW = raw_input().split()
hw = raw_input().split()

print(int(HW[0]) * int(HW[1]) - int(HW[0]) * int(hw[1]) - int(HW[1]) * int(hw[0]) + int(hw[0]) * int(hw[1]))
import numpy as np

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

cost = np.zeros(n)


for i in range(1,n):
    left = max(0,i-k)
    cost[i] = cost[left:i]+abs(h[i]-h[left:i]).min()
     

print(int(cost[-1]))


### FIXED CODE ###

import numpy as np

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

cost = np.zeros(n)


for i in range(1,n):
    left = max(0,i-k)
    cost[i] = (cost[left:i]+abs(h[i]-h[left:i])).min()
     

print(int(cost[-1]))
a,b=int(input().split())
if a-(b＊2)<=0:
  
  print(0)
else:
  print(a-(b＊2))
  


### FIXED CODE ###

a,b=map(int,input().split())
if a-b*2<=0:
  
  print(0)
else:
  print(a-b*2)
import sys
args = sys.argv[1]
#??????????????????????????????????????????????????§????????????????????????
with open(args) as f:
	x = f.readlists()
	i = 0
	while x[i] != 0:
		print("Case " + str(i+1) + ":" + str(x))
		i += 1
		

### FIXED CODE ###

#x = []
i = 0
while True:
	x = int(input())
	if x == 0:
		break
	print("Case " + str(i+1) + ": " + str(x))
	i += 1
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)

# def seive():
#     prime=[1 for i in range(10**6+1)]
#     prime[0]=0
#     prime[1]=0
#     for i in range(10**6+1):
#         if(prime[i]):
#             for j in range(2*i,10**6+1,i):
#                 prime[j]=0


a,b,c,d=l()
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//gcd(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)

### FIXED CODE ###

def G(x,y):
    if(x<y):
        x,y=y,x
    if(y==0):
        return x
    return G(y,x%y)


a,b,c,d=map(int,input().split())
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//G(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

ans = A[len(A) - 1] - A[0]
small = 0
large = len(A) - 1
while (True):

    if large - small == 1:
        break
    elif large - small == 2:
        ans += max(A[large] - A[large - 1], A[small + 1] - A[small])
        break
    ans += A[large - 1] - A[small] + A[large] - A[small + 1]
    small += 1
    large -= 1

print(ans)


### FIXED CODE ###

S = input()
if len(S) == 2:
    print(S)
else:
    print(S[::-1])
n, k = map(int, input().split())
p = list(map(int, input().split()))

p_max = max(p)

l_range = list(range(1001))
st = [sum(l_range[:i]) for i in range(1001)][1:]
#print(st)
table = [0] * (n + 1)
for i in range(1, len(table)):
    table[i] = table[i-1] + (st[p[i-1]] / p[i-1])
    #print(i, p[i-1], st[p[i-1]], table[i])
    
ans = table[k]
for i in range(k+1, len(table)):
    ans = max(ans, table[i] - table[i-k])

print(ans)



### FIXED CODE ###

from itertools import accumulate

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

st = list(accumulate(range(1001)))
#print(st)
table = [0] * (n + 1)
for i in range(1, len(table)):
    table[i] = table[i-1] + (st[p[i-1]] / p[i-1])
    #print(i, p[i-1], st[p[i-1]], table[i])
    
ans = table[k]
for i in range(k+1, len(table)):
    ans = max(ans, table[i] - table[i-k])

print(ans)
n,k = map(int,input().split())
a = tuple(map(int,input().split()))
mod = 10**9+7
rng = 1001
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
dp = [[0 for i in range(n+1)] for j in range(k+1)]
dp[0][0] = 1
for i in range(1,k+1):
  x = a[i-1]
  for j in range(n+1):
    for t in range(min(n-j,x)+1):
      dp[i][j+t]=(dp[i][j+t]+dp[i-1][j]*fctr[n-j]*finv[n-j-t]*finv[t]*fctr[n-t]*finv[x-t]*finv[n-x])%mod
print(dp[k][n])

### FIXED CODE ###

n = int(input())
a = [list(input().split()) for i in range(n)]
b = input()
flg = 0
ans = 0
for i in range(n):
  if a[i][0] == b:
    flg = 1
  elif flg:
    ans += int(a[i][1])
print(ans)
n=int(input())
a=list(map(int,input().split()))
a1=0
b=0
c=0
d=0
e=0
f=0
g=0
h=0
ans=0
for i in range(n):
  if 1<=a[i]<=399:
    a1=1
  elif 400<=a[i]<=799:
    b=1
  elif 800<=a[i]<=1199:
    c=1
  elif 1200<=a[i]<=1599:
    d=1
  elif 1600<=a[i]<=1999:
    e=1
  elif 2000<=a[i]<=2399:
    f=1
  elif 2400<=a[i]<=2799:
    g=1
  elif 2800<=a[i]<=3199:
    h=1
  else:
    ans+=1

x=a1+b+c+d+e+f+g+h
if a1=b=c=d=e=f=g=h=0:
  print(1,ans)
else:
  print(x,x+ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a1=0
b=0
c=0
d=0
e=0
f=0
g=0
h=0
ans=0
for i in range(n):
  if 1<=a[i]<=399:
    a1=1
  elif 400<=a[i]<=799:
    b=1
  elif 800<=a[i]<=1199:
    c=1
  elif 1200<=a[i]<=1599:
    d=1
  elif 1600<=a[i]<=1999:
    e=1
  elif 2000<=a[i]<=2399:
    f=1
  elif 2400<=a[i]<=2799:
    g=1
  elif 2800<=a[i]<=3199:
    h=1
  else:
    ans+=1

x=a1+b+c+d+e+f+g+h
if a1==b==c==d==e==f==g==h==0:
  print(1,ans)
else:
  print(x,x+ans)
n = int(input())
S = input().split()
q = int(input())
T = input().split()
cnt = 0

for i in range(len(S)):
    S[i]=int(S[i])
for i in range(len(T)):
    T[i]=int(T[i])
for i in range(len(S)):
    x=0
    light=0
    reft=n
    while left<right and x==0:
        mid=int((left+right)/2)
        if S[mid]==T[i]:
            cnt+=1
            x+=1
        elif T[i]<S[mid]:
            right=mid
        else:
            left=mid+1
print(cnt)



### FIXED CODE ###

def binarySearch(array, key):
    left = 0
    right = len(array)
    while left < right:
        mid = int((left + right) / 2)
        if key == array[mid]:
            return True
        elif key > array[mid]:
            left = mid + 1
        elif key < array[mid]:
            right = mid
        else:
            print("ERROR")
    return False
 
 
n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]
a = [x for x in t if binarySearch(s, x)]
print(len(a))
N=int(input())
M=list(map(int, input().split()))
ans=min(M)
mn=Min(M)
from math import gcd
for m in M:
  if m%ans!=0:
    ans=min(ans, gcd(mn,m))
print(ans)

### FIXED CODE ###

N=int(input())
M=list(map(int, input().split()))
ans=min(M)
mn=min(M)
from math import gcd
for m in M:
  if m%mn!=0:
    ans=min(ans, gcd(mn,m))
print(ans)
l = list(map(int, input()))
if 7 in list:
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

l = list(map(int, input()))
if 7 in l:
  print("Yes")
else:
  print("No")
A,X = map(int,imput().split())
if X<A:
  print(0)
if x>=A:
  print(10)

### FIXED CODE ###

X,A = map(int,input().split())
if X<A:
  print(0)
if X>=A:
  print(10)
while(1):
  table, output = [], []
  table_number = input()
  string = ''
  if table_number == 0:
    break
  for i in table_number:
    table.append(raw_input().split())
  string_number = input()
  for i in string_number:
    string = input()
    for table_element in table:
      if tabole_element[0] == string:
        string =table_element[1]
    output += string
  print output

### FIXED CODE ###

while(1):
  table = {}
  output = ''
  table_number = int(input())
  if table_number == 0:
    break
  for i in xrange(table_number):
    a, b = raw_input().split()
    table[a] = b
  string_number = int(input())
  for i in xrange(string_number):
    string = raw_input()[0]
    if string in table:
      output += table[string]
    else:
      output += string
  print output
import sys, math

input = sys.stdin.readline
gcd = math.gcd
A, B, C, D = map(int, input().split(' '))
num = B - A + 1
div_c = B // C - (A - 1) // C
div_d = B // D - (A - 1) // D
lcd = C * D // gcd(C, D)
div_cd = B // lcd - (A - 1) // lcd
print(num - div_c - div_d + div_cd)

### FIXED CODE ###

import sys
from fractions import gcd

input = sys.stdin.readline
A, B, C, D = map(int, input().split(' '))
num = B - A + 1
div_c = B // C - (A - 1) // C
div_d = B // D - (A - 1) // D
lcd = C * D // gcd(C, D)
div_cd = B // lcd - (A - 1) // lcd
print(num - div_c - div_d + div_cd)
import sys
input=sys.stdin.readline
n,m,l=map(int,input().split())
INF=10**10
graph=[[INF for i in range(n)] for j in range(n)]
fuel=[[INF for i in range(n)] for j in range(n)]
for i in range(n):
    graph[i][i]=0
for i in range(m):
    a,b,c=map(int,input().split())
    a-=1;b-=1
    if c>l:continue
    graph[a][b],graph[b][a]=c,c
for i in range(n):
  for j in range(n):
    for k in range(n):
      graph[j][k]=min(graph[j][k],graph[j][i]+graph[i][k])
for i in range(n):
    for j in range(n):
        if graph[i][j]<=l:
            fuel[i][j]=1
for i in range(n):
  for j in range(n):
    for k in range(n):
      fuel[j][k]=min(fuel[j][k],fuel[j][i]+fuel[i][k])
q=int(input())
for i in range(q):
    s,t=map(int,input().split())
    s-=1;t-=1
    if fuel[s][t]==INF:print(-1)
    else:print(fuel[s][t]-1)


### FIXED CODE ###

a,b=map(int,input().split())
print(max(0,a-2*b))
import sys
x=int(input())
b=0
while True:
  if ((b**5+x)**(1/5)).is_integer():
    print(int((b**5+x)**(1/5)),b)
    sys.exit()
  elif ((x-b**5)**(1/5)).is_integer():
    print(int((x-b**5)**(1/5)),-1*b)
    sys.exit()
  else:
    b+=1

### FIXED CODE ###

import sys
x=int(input())
for a in range(-200,200):
  for b in range(-200,200):
    if a**5-b**5 ==x:
      print(a,b)
      sys.exit()
import sys
a = 1

for x in sys.stdin.strip():
        if x == "0":
                break;
        print("Case {}: {}".format(a,x))
        a += 1

### FIXED CODE ###

import sys
a = 1

for i in sys.stdin:
        x = i.strip()
        if x == "0":
                break;
        print("Case {0}: {1}".format(a,x))
        a += 1
def gcdf(a,n,gcdv):
#    print("a:",a)
    a0=a[0]
    ramin=10**9
    ramin0=20**9
    while ramin0!=ramin:
        ramin0=ramin
        for i in range(n):
            a[i]=a[i]%a0
            if a[i]==0:
                a[i]=a0
            if ramin>a[i]:
                ramin=a[i]
            if ramin<=gcdv:
                return gcdv
        a0=min(a)
#        print("a:",a,ramin)
    return ramin


#n=2
#a=[1000000000, 1000000000]
#n=4
#a=[15, 18, 24, 36]
n=int(input())

a=[]
for i in map(int,input().split()):
    a.append(i)

#print(a)
if n==2:
    print(max(a))
elif n>=16:
    a.sort()
    ns=int(n/4)
    a1=a[0:ns]
    a2=a[ns:ns*2]
    a3=a[ns*2:ns*3]
    a4=a[ns*3:n]
    gcdv=0
    gcd1=gcdf(a1,len(a1),gcdv)
    gcd2=gcdf(a2,len(a2),gcdv)
    gcd3=gcdf(a3,len(a3),gcdv)
    gcd4=gcdf(a4,len(a4),gcdv)
    for i in range(ns):
        acpy=list(a1)
        acpy.append(gcd2)
        acpy.append(gcd3)
        acpy.append(gcd4)
        del acpy[i]
        gcdx=gcdf(acpy,len(acpy),gcdv)
        if gcdx>gcdv:
            gcdv=gcdx
    for i in range(ns):
        acpy=list(a2)
        acpy.append(gcd1)
        acpy.append(gcd3)
        acpy.append(gcd4)
        del acpy[i]
        gcdx=gcdf(acpy,len(acpy),gcdv)
        if gcdx>gcdv:
            gcdv=gcdx
    for i in range(ns):
        acpy=list(a3)
        acpy.append(gcd1)
        acpy.append(gcd2)
        acpy.append(gcd4)
        del acpy[i]
        gcdx=gcdf(acpy,len(acpy),gcdv)
        if gcdx>gcdv:
            gcdv=gcdx
    for i in range(ns):
        acpy=list(a4)
        acpy.append(gcd1)
        acpy.append(gcd2)
        acpy.append(gcd3)
        del acpy[i]
        gcdx=gcdf(acpy,len(acpy),gcdv)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)
    
else:
    gcdv=0
    a.sort()
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        gcdx=gcdf(acpy,n-1,gcdv)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)


### FIXED CODE ###

icase=0
if icase==0:
    a,b,t=map(int,input().split())
    n=(t+0.5)//a
    print(b*int(n))
import statistics
n = int(input())
a = list(map(int,input().split()))

mean = round(statistics.mean(a))

ans = 0
for i in range(n):
    ans += (a[i]-mean)**2

print(ans)

### FIXED CODE ###

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

mean = round(statistics.mean(a))

ans = 0
for i in range(n):
    ans += (a[i]-mean)**2

print(ans)