Harryxun/stf_run huggingface dataset:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    f = [{} for _ in range(N+1)] # [{arg:k}]
    f[6] = {(1,1,1):1}
    for i in range(N):
        args = f[i]
        for (x,y,z),k in args.items():
            index = i + 2*x + y + z + 1
            arg = (x+1,y,z)
            if index < N+1:
                f[index][arg] = 1
            index = i + x + 2*y + z + 1
            arg = (x,y+1,z)
            if index < N+1:
                f[index][arg] = 1
            index = i + x + y + 2*z + 1
            arg = (x,y,z+1)
            if index < N+1:
                f[index][arg] = 1

    for i in range(1,N+1):
        print(sum(f[i].values()))


main()


### FIXED CODE ###

#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    f = [{} for _ in range(N+1)] # [{arg:k}]
    if len(f) > 6:
        f[6] = {(1,1,1):1}
    for i in range(N):
        args = f[i]
        for (x,y,z),k in args.items():
            index = i + 2*x + y + z + 1
            arg = (x+1,y,z)
            if index < N+1:
                f[index][arg] = 1
            index = i + x + 2*y + z + 1
            arg = (x,y+1,z)
            if index < N+1:
                f[index][arg] = 1
            index = i + x + y + 2*z + 1
            arg = (x,y,z+1)
            if index < N+1:
                f[index][arg] = 1

    for i in range(1,N+1):
        print(sum(f[i].values()))


main()
a = list(map(str, input().split()))
b = list(map(str, input().split()))
c = list(map(str, input().split()))

print(a[0]+b[1]+c[2], end='')

### FIXED CODE ###

a = list(map(str, input()))
b = list(map(str, input()))
c = list(map(str, input()))

print(a[0]+b[1]+c[2], end='')
a,b= input() , input()
 

print a * b ,
print a * 2 + b * 2

### FIXED CODE ###


l = map(int, raw_input().split())
 
print "%d %d" % (l[0]*l[1], (l[0]+l[1])*2)
A,B,C,D = map(int,input().split())

if (B < C or D < A):
    print("0")
else:
    print(abs(max(A,C)-min(B,D)))

### FIXED CODE ###

N = input()
if N[0] == N[2]:
    print("Yes")
else:
    print("No")
n=int(input())
s=input()
lst=list(s)
r=[i for i,j in enumerate(lst) if j=="R"]
g=[i for i,j in enumerate(lst) if j=="G"]
b=[i for i,j in enumerate(lst) if j=="B"]
comb=len(r)*len(g)*len(b)
out=0
for i in r:
  for j in g:
    for k in b:
      if (i+j)==2*k or (j+k)==2*i or (k+i)==2*j:
        out+=1
print(comb-out)


### FIXED CODE ###

from collections import deque
d=deque(input())
if "7" in d:
  print("Yes")
else:
  print("No")
import sys
from heapq import heappop as p
sys.setrecursionlimit(9**9)
n=int(input())
T=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    T[a-1].append([b-1,i])
C=[0]*(n-1)
m=max(map(lambda x:lem(x),T))
def f(Q):
    R=[]
    for q in Q:
        H=list(range(1,m))
        for t in T[q[0]]:
            x=p(H)
            if x==q[1]:
                x=p(H)
            C[t[1]]=x
            if len(T[t[0]])!=0:
            	R.append([t[0],x])
    if len(R)!=0:
    	return f(R)
f([[0,0]])
print(max(C))
for c in C:
    print(c)

### FIXED CODE ###

import sys
sys.setrecursionlimit(9**9)
n=int(input())
T=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    T[a-1].append([b-1,i])
C=[0]*(n-1)
def f(i,r):
    c=1
    for (x,y) in T[i]:
        c+=(c==r)
        C[y]=c
        f(x,c)
        c+=1
f(0,0)
print(max(C))
for c in C:
    print(c)
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    cos = []
    row = []
    col = []
    for _ in range(m):
        a,b,c = map(int,ipt().split())
        row.append(a-1)
        col.append(b-1)
        cos.append(c)
        cos.append(c)
    csr = csr_matrix((cos,(row,col)),shape=(n,n))
    d = dijkstra(csr,directed=False)
    ans = 0
    for i in range(m):
        csr = csr_matrix((cos[:i:]+cos[i+1::],(row[:i:]+row[i+1::],col[:i:]+col[i+1::])),shape=(n,n))
        di = dijkstra(csr)
        if (di == d).all():
            ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    cos = []
    row = []
    col = []
    for _ in range(m):
        a,b,c = map(int,ipt().split())
        row.append(a-1)
        col.append(b-1)
        cos.append(c)
    csr = csr_matrix((cos,(row,col)),shape=(n,n))
    d = dijkstra(csr,directed=False)
    ans = 0
    for i in range(m):
        rwi = row[i]
        cli = col[i]
        csi = cos[i]
        dri = d[rwi]
        dci = d[cli]
        for j in range(n):
            if dri[j] + csi == dci[j]:
                break
            if j == n-1:
                ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()
n = int(input())
s = [int(input()) for _ in range(n)]
m = int(input())
t = [int(input()) for i in range(m)]

l = []
for i in range(n):
  S = s.count(i)
  T = t.count(i)
  l.append(S - T)
  
if max(l) < 0:
  print("0")
else:
  print(max(l))

### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

l = []
for i in range(n):
  S = s.count(s[i])
  T = t.count(s[i])
  l.append(S - T)
  
if max(l) < 0:
  print(0)
else:
  print(max(l))
S=str(input())
import sys
t=0
lista=[]
for i in range(99):
  try:
    lista.append(S[i])
    t=t+1
  except IndexError:
    break
u=t//2
v=u//2+1
p=1
for i in range(v):
  if S[i]==S[u-i-1]:
    p=p*1
  else:
    print ('No')
    sys.exit()
for j in range(v):
  if S[u+j+1]==S[t-1-j]:
    p=p*1
  else:
    print ('No')
    sys.exit()
if t>3:
  print ('Yes')
else:
  if S[0]=S[2]:
    print ('Yes')
  else:
    print ('No')

### FIXED CODE ###

S=str(input())
import sys
t=0
lista=[]
for i in range(99):
    try:
        lista.append(S[i])
        t=t+1
    except IndexError:
        break
u=t//2
v=u//2+1
p=1
for i in range(v):
    if S[i]==S[u-i-1] and S[u-i-1]==S[u+i+1] and S[u+i+1]==S[t-1-i]:
        p=p*1
    else:
        print ('No')
        sys.exit()
print ('Yes')
n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print(*s,sep="")

### FIXED CODE ###

import sys
input = sys.stdin.readline

a,b,c = sorted(list(map(int,input().split())))
print('YES' if a==b and b==5 and c==7 else 'NO')
H,W = map(int,input().split())
h,w = map(int,input().split())
tot = H*W 
print(tot - {(h*W)+(w*H)-(h*w)})

### FIXED CODE ###

H,W = map(int,input().split())
h,w = map(int,input().split()) 
print(H*W - ((h*W)+(w*H)-(h*w)))
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for i in range(Q)]
d = [0] * (H*W)
num_dict = {}
y = 0
for aa in A:
    x = 0
    for a in aa:
        num_dict[a] = [x, y]
        x += 1
    y += 1

for i in range(D+1, H*W):
    d[i] = d[i-D] + abs(num_dict[i][0]-num_dict[i-D][0]) + abs(num_dict[i][1]-num_dict[i-D][1])
for l, r in LR:
    print(d[r]-d[l])


### FIXED CODE ###


H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for i in range(Q)]
d = [0] * ((H*W)+1)
num_dict = {}
y = 0
for aa in A:
    x = 0
    for a in aa:
        num_dict[a] = [x, y]
        x += 1
    y += 1

for i in range(D+1, H*W+1):
    d[i] = d[i-D] + abs(num_dict[i][0]-num_dict[i-D][0]) + abs(num_dict[i][1]-num_dict[i-D][1])
for l, r in LR:
    print(d[r]-d[l])
n = int(input())
a = tuple(map(int, input().split()))
dp = [(0,) * n for _ in range(n)]
for i in range(n):
    dp[i][i] = a[i]

for i in range(n - 2, -1, -1):
    for j in range(i + 1, n):
        dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])

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

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
dp = [[0] * n for _ in range(n)]
for i in range(n):
    dp[i][i] = a[i]

for i in range(n - 2, -1, -1):
    for j in range(i + 1, n):
        dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])

print(dp[0][n - 1])
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

N_list = [i for i in range(1,N)]
conbination = list(itertools.permutations(N_list, 8))

a = conbination.index(tuple(P))
b = conbination.index(tuple(Q))

print(abs(a-b))


### FIXED CODE ###

import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

N_list = [i for i in range(1,N+1)]
conbination = list(itertools.permutations(N_list, N))

a = conbination.index(tuple(P))
b = conbination.index(tuple(Q))

print(abs(a-b))
N, *X = map(int, open(0).read().split())

ans = 0
for i in range(N - 1):
    if X[i] == i + 1:
        X[i], X[j] = X[j], X[i]
        ans += 1

print(ans)


### FIXED CODE ###

N, *X = map(int, open(0).read().split())

ans = 0
for i in range(N):
    if X[i] == i + 1:
        if i < N - 1:
            X[i], X[i + 1] = X[i + 1], X[i]
        else:
            X[i - 1], X[i] = X[i], X[i - 1]
        ans += 1

print(ans)
sa=input()
sb=input()
sc=input()
i=sa[0]
sa=sa[1:]
while 1:
    if i=="a":i,sa=sa[0],sa[1:]
    elif i=="b":i,sb=sb[0],sb[1:]
    elif i=="c":i,sc=sc[0],sc[1:]
    if i=="a" and sa=="":
        print("A")
        break
    elif i=="b" and sb=="":
        print("B")
        break
    elif i=="c" and sc=="":
        print("C")
        break

### FIXED CODE ###

a=list(input().replace("a",""))
b=list(input().replace("b",""))
c=list(input().replace("c",""))
t=0
while 1:
    if t==0:
        if len(a)==0:
            print("A")
            break
        else:
            t=ord(a.pop(0))-97
    elif t==1:
        if len(b)==0:
            print("B")
            break
        else:
            t=ord(b.pop(0))-97
    elif t==2:
        if len(c)==0:
            print("C")
            break
        else:
            t=ord(c.pop(0))-97
a,b = map(int,input().split())

if b => a:
  print(a)
else:
  print(a-1)

### FIXED CODE ###

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

if a <= b:
  print(a)
  
else:
  print(a-1)
N,X=map(int, input().split()) 
L=list(map(int, input().split())) 
D = 0
for i in range(N):
  D = D + L[i]
  print(L[i])
  if D > X:
    print(i+1)
    break
  if D == X:
    print(i+2)
    break


### FIXED CODE ###

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

if X < A:
  print(0)
else:
  print(10)
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

### FIXED CODE ###

n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0) for xi, yi, hi in xyh if hi == 0)):
                print(cx, cy, H)
                exit()
import numpy as np
i4 = np.int32
i8 = np.int64


def find(x, parents):
    if parents[x] == x:
        return x
    else:
        return find(parents[x], parents)


def union (x, y, parents, depth):
    x = find(x, parents)
    y = find(y, parents)
    if x == y:
        return

    if depth[x] == depth[y]:
        depth[x] += 1
        parents[y] = x
    elif depth[x] > depth[y]:
        parents[y] = x
    else:
        parents[x] = y


def main(in_file):
    stdin = open(in_file)
    N, M = [int(x) for x in stdin.readline().split()]
    a = np.empty(M, i8)
    b = np.empty(M, i8)
    for i in range(M):
        a[i], b[i] = [int(x) - 1 for x in stdin.readline().split()]
    parents = np.arange(N)
    depth = np.zeros(N, i8)
    for i in range(M):
        union(a[i], b[i], parents, depth)
    num = np.zeros(M, i8)
    for i in range(N):
        p = find(i, parents)
        num[p] += 1
    ans = num.max()
    print(ans)


main('/dev/stdin')

### FIXED CODE ###

import numpy as np
i4 = np.int32
i8 = np.int64


def find(x, parents):
    if parents[x] == x:
        return x
    else:
        return find(parents[x], parents)


def union (x, y, parents, depth):
    x = find(x, parents)
    y = find(y, parents)
    if x == y:
        return

    if depth[x] == depth[y]:
        depth[x] += 1
        parents[y] = x
    elif depth[x] > depth[y]:
        parents[y] = x
    else:
        parents[x] = y


def main(in_file):
    stdin = open(in_file)
    N, M = [int(x) for x in stdin.readline().split()]
    a = np.empty(M, i8)
    b = np.empty(M, i8)
    for i in range(M):
        a[i], b[i] = [int(x) - 1 for x in stdin.readline().split()]
    parents = np.arange(N)
    depth = np.zeros(N, i8)
    for i in range(M):
        union(a[i], b[i], parents, depth)
    num = np.zeros(N, i8)
    for i in range(N):
        p = find(i, parents)
        num[p] += 1
    ans = num.max()
    print(ans)


main('/dev/stdin')
N = list(map(int, input()))
N = N[::-1] + [0]

count = 0

def moveUp(i):
  if N[i] == 9:
    N[i] = 0
    moveUp(i+1)
  else:
    N[i] += 1

for i, n in enumerate(N):
  if n < 5:
    count += n
  elif n > 5:
    count += 10 - n
    moveUp(i+1)
  elif n == 5:
    for j in range(i+1, len(N)):
      if N[j] < 5:
        break
      if N[j] >= 5:
        moveUp(i+1)
        break
      
    count += 5
print(count)

### FIXED CODE ###

N = list(map(int, input()))
N = N[::-1] + [0]

count = 0

for i, n in enumerate(N):
  if n < 5:
    count += n
  elif n > 5:
    count += 10 - n
    N[i+1] += 1
  elif n == 5:
    if N[i+1] >= 5:
      N[i+1] += 1
    count += 5
    
print(count)
L=int(input())
R=int(input())
d=int(input())
count=int(0)
for i in range(L,R):
    if i%d==0:
        count+=1
print(count)

### FIXED CODE ###

L,R,d = map(int,input().split())
count=int(0)
for i in range(L,R+1):
    if i%d==0:
        count+=1
print(count)
d=[0]*13
d[0]=1
mul=1
t=reversed(input())
for c in reversed(input()):
    e=[0]*13
    """
    if c=="?":
        for i in range(10):
            for j in range(13):
                e[(i*mul+j)%13]+=d[j]
                e[(i*mul+j)%13]%=(10**9+7)
    else:
        for j in range(13):
            e[(int(c)*mul+j)%13]+=d[j]
            e[(int(c)*mul+j)%13]%=(10**9+7)
    """
    for i in (range(10) if c=="?" else[int(c)]):
        for j in range(13):
            e[(i*mul+j)%13]+=d[j]
            
    d=[e%(10**9+7)for e in e]
    mul*=10
print(d[5])



### FIXED CODE ###

# coding: utf-8
# Your code here!
 
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意
 
s = input()
l = len(s)
MOD = 10**9+7
 
dp = [0]*13
dp[0] = 1
for i in s:
    new = [0]*13
    if i == "?":
        for i in range(10):
            for j in range(13):
                new[(10*j+i)%13] += dp[j]
    else:
        i = int(i)
        for j in range(13):
            new[(i+10*j)%13] += dp[j]
    
    for i in range(13):
        new[i] %= MOD
    dp,new = new,dp
#    print(dp)
 
print(dp[5]%MOD)
n=int(input())
nums=list(map(int,input()))
count=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if nums[j] < nums[minj]:
            minj=j
    if not i==minj:
        v=nums[i]
        nums[i]=nums[minj]
        nums[minj]=v
        count+=1
print(*nums)
print(count)


### FIXED CODE ###

N = int(input())
*A, = map(int,input().split())
count = 0
for i in range(N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j
    if not minj == i:
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
        count += 1
    
print(*A)
print(count)
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x+y
    ans += 1 if z>=0 and z<=k
print(ans)

### FIXED CODE ###

k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    ans += 1 if z>=0 and z<=k else 0
print(ans)
n=input()
s=sum(int(c) for c in n)
if n%9==0:
  print('Yes')
else:
  print('No')



### FIXED CODE ###

n=input()
s=sum(int(c) for c in n)
if s%9==0:
  print('Yes')
else:
  print('No')
l,r = map(int,input().split())

for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans = min(ans,(i%2019*j%2019)%2019)
print(ans)

### FIXED CODE ###

l,r = map(int,input().split())
if r-l>=2019:
    print(0)
    exit()
ans = 2019
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans = min(ans,(i*j)%2019)
print(ans)
import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for _ in range(A)]+[INF]
T = [-INF]+[int(input()) for _ in range(B)]+[INF]

ans = []
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[i-1],T[i]]:
            d1 = abs(x-s) + abs(s-t)
            d2 = abs(x-t) + abs(s-t)
            d = min(d,d1,d2)
    ans.append(d)
for i in ans:
    print(i)

### FIXED CODE ###

import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for i in range(A)]+[INF]
T = [-INF]+[int(input()) for i in range(B)]+[INF]
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1 = abs(s-x)+abs(s-t)
            d2 = abs(t-x)+abs(s-t)
            d = min(d,d1,d2)
    print(d)
L=amp(int,input().split())
table=[5,5,7]
L=soretd(L)
if table == L:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

L=list(map(int,input().split()))
table=[5,5,7]
L=sorted(L)
if table == L:
  print("YES")
else:
  print("NO")
s = input()
print('Yes' if s.index('C') < s.rindex('F') else 'No')

### FIXED CODE ###

s = input()
flag = False
if 'C' in s and 'F' in s and s.index('C') < s.rindex('F'):
  flag = True
  
print('Yes' if flag == True else 'No')
r = int(input())
pi = 3.14159265359
print("%.6f %.6f" %(pi*r*r,2*pi*r))


### FIXED CODE ###

r = float(input())
pi = 3.14159265359
print("%.6f %.6f" %(pi*r*r,2*pi*r))
"""
問題文

N個の整数 A1,A2,...,ANが黒板に書かれています。
あなたはこの中から整数を 1つ選んで、1 以上 109以下の好きな整数に書き換えます。
元の整数と同じ整数に書き換えても構いません。書き換えた後のN個の整数の最大公約数の最大値を求めてください。

制約
入力は全て整数である。
2≤N≤105
1≤Ai≤109
"""

"""
3 5 7
最大公約数: 1
最大の最大公約数: 1

8 4 6
最大公約数: 2
最大の最大公約数: 4
『aとbとcの最大公約数』　＝　『aとbの最大公約数』と『c』　の最大公約数

A1 , A2 , A3 ... An

gcd(A1 , A2 , A3 ... An-1) * N
= gcd * N * N
= gcd * N^2

gcd(A1 , A2 , A3 ... An-1)
gcd(A1 , A2 , A3 ... An-2 , An) = gcd(A1 , A2 , A3 ... An-2) , An
"""
from math import gcd
from fractions import gcd  # for Ver.3.4 or lower.
#from functools import reduce
gcd_map = {}
def GCD(numbers , startIndex , endIndex):
    if len(numbers) == 0 : return 0
    if len(numbers) == 1 : return numbers[0]
    if len(numbers) == 2 : 
        return gcd(numbers[0] , numbers[1])
    else : 
        set_index = (startIndex , endIndex)
        if set_index in gcd_map : 
            return gcd_map[set_index]
        value = GCD(numbers[1:] , startIndex + 1 , endIndex)
        result = gcd(value , numbers[0])
        gcd_map[set_index] = result
        return result

def main() : 
    N = int(input())
    a_list = input().split(" ")
    a_list = [int(i) for i in a_list]
    maxValue = 0
    for i in range(N) : 
        if i == 0 : 
            prev_list = a_list[1:]
            rst = GCD(prev_list , 1 , N - 1)
        elif i == N - 1 : 
            after_list = a_list[:N-1]
            rst = GCD(after_list , 0 , N - 2)
        else : 
            prev_list = a_list[0 : i ]
            after_list = a_list[i + 1 :] 
            rst = gcd(GCD(prev_list , 0 , i - 1) , GCD(after_list , i + 1 , N - 1))
        if maxValue < rst : maxValue = rst
    print(maxValue)
main()


### FIXED CODE ###

"""
問題文

N個の整数 A1,A2,...,ANが黒板に書かれています。
あなたはこの中から整数を 1つ選んで、1 以上 109以下の好きな整数に書き換えます。
元の整数と同じ整数に書き換えても構いません。書き換えた後のN個の整数の最大公約数の最大値を求めてください。

制約
入力は全て整数である。
2≤N≤105
1≤Ai≤109
"""

"""
3 5 7
最大公約数: 1
最大の最大公約数: 1

8 4 6
最大公約数: 2
最大の最大公約数: 4
『aとbとcの最大公約数』　＝　『aとbの最大公約数』と『c』　の最大公約数

A1 , A2 , A3 ... An

gcd(A1 , A2 , A3 ... An-1) * N
= gcd * N * N
= gcd * N^2

gcd(A1 , A2 , A3 ... An-1)
gcd(A1 , A2 , A3 ... An-2 , An) = gcd(A1 , A2 , A3 ... An-2) , An
"""
def gcd(a, b):  # a>b
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

from functools import reduce
def GCD(numbers):
    if len(numbers) == 0 : return 0
    if len(numbers) == 1 : return numbers[0]
    if len(numbers) == 2 : 
        return gcd(numbers[0] , numbers[1])
    else : 
        value = GCD(numbers[:len(numbers)-1])
        result = gcd(value , numbers[len(numbers) - 1])
        return result

def main() : 
    N = int(input())
    a_list = input().split(" ")
    a_list = [int(i) for i in a_list]
    R = [0 for i in range(N - 1)]
    L = [0 for i in range(N - 1)]
    R[0] = a_list[0]
    L[0] = a_list[-1]

    for i in range(1 , N-1) : 
        R[i] = gcd(R[i - 1] , a_list[i])
    
    for j in range(1 , N-1) : 
        L[j] = gcd(L[j - 1] , a_list[- j - 1])
    
    maxValue = 0
    for i in range(N - 2) : 
        value = gcd(R[i] , L[N - i - 3])
        if value > maxValue : maxValue = value
    print(max(maxValue , R[-1] , L[-1]))
main()
a = list(map(int, input().split()))
a.sort()
if a == [5, 5, 7];
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a = list(map(int, input().split()))
a.sort()
if a == [5, 5, 7]:
  print("YES")
else:
  print("NO")
N=int(input())
ld=list(map(int,input().split()))
if ld[0]!=0:
    print(0)
else:
    dd={}
    for i in range(N):
        if ld[i] in dd:
            dd[ld[i]]+=1
        else:
            dd[ld[i]]=1
    if dd[0]!=1:
        print(0)
    else:
        DV=998244353
        ans=1
        for i in range(0,len(dd)-1):
            mul=dd[i]**dd[i+1]%DV
            #ans*=dd[i]**dd[i+1]
            ans*=mul
            ans%=DV
        print(ans)


### FIXED CODE ###

N=int(input())
ld=list(map(int,input().split()))
def modpow(a,n,p):#a^n mod p
    res=1
    while n>0:
        if n&1:#１とのビット論理積が１、つまり奇数
            res=res*a%p
        a=a*a%p
        n>>=1
        #ビットの右シフト_2進数表記のnを小数点を固定して右に１桁ずらす_１桁小さくなる
    return res
if ld[0]!=0:
    print(0)

else:
    dd={}
    for i in range(N):
        if ld[i] in dd:
            dd[ld[i]]+=1
        else:
            dd[ld[i]]=1

    if dd[0]!=1:
        print(0)
    else:
        DV=998244353
        ans=1
        for i in range(0,len(dd)-1):
            #mul=dd[i]**dd[i+1]%DV
            if i in dd and i+1 in dd:
                mul=modpow(dd[i],dd[i+1],DV)
                #ans*=dd[i]**dd[i+1]
                ans*=mul
                ans%=DV
            else:
                print(0)
                break
        else:
            print(ans)
n = int(input())
    a = list(map(int, input().split()))
    seta = set(a)
    ans = 'YES' if len(a) == len(seta) else 'NO'
    print(ans)    

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
seta = set(a)
if len(a)==len(seta):
  print("YES")
else:
  print("NO")
n=int(input())
from itertools import groupby as gb
ans=0
for a,b in gb(list(map(int,input().split()))):
    ans+=b//2
print(ans)

### FIXED CODE ###

n=int(input())
from itertools import groupby as gb
ans=0
for a,b in gb(list(map(int,input().split()))):
    ans+=len(list(b)) //2
print(ans)