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

import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors


def main():

    N = in_n()
    A = list(in_nn())

    d = dict()
    for i in range(N):
        if A[i] in d:
            d[A[i]] += 1
        else:
            d[A[i]] = 1

    ans = 0
    for i in range(N):
        for num in make_divisors(A[i]):
            if num == A[i]:
                if d.get(num, 0) >= 2:
                    break
            else:
                if d.get(num, 0) >= 1:
                    break
        else:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    A = sorted(list(in_nn()))

    maxA = max(A)
    ans = [True] * (maxA + 1)
    d = set()

    for i in range(N):
        if A[i] in d:
            ans[A[i]] = False
        for j in range(A[i] * 2, maxA + 1, A[i]):
            if not j:
                break
            else:
                ans[j] = False
        d |= {A[i]}

    count = 0
    for i in range(N):
        count += ans[A[i]]

    print(count)


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

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

max_e=0
for i in range(N-(K-1)):
  v=p[i:K+i]
  smax=sum(v)
  e=(K+smax)/2

  if max_e<e:
    max_e=e
    
print(max_e)

### FIXED CODE ###

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

p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=e
for i in range(1,N-K):
  e=s[i+K]-s[i]
  max_e = max(max_e, e)
    
print(max_e)
### BUGGY CODE ###

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

count=0
for i in range(b-a+1):
    if (a+i)%x == 0 :
        count+=1
        count+=(b-a-i)//x
        break
print(count)


### FIXED CODE ###

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

count=0
if a==0 :
    count+=1

if a<=x :
    ai = x
else:
    ai = (a//x)*x
    if ai<a :
        ai +=x
if ai<=b :
    count+=1
    count+=(b-ai)//x

print(count)
### BUGGY CODE ###

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n, k = ZZ()
    A = ZZ() + [0]

    for _ in range(k):
        if A[0] >= n+1: break
        nA = [0] * (n+1)
        for i in range(n):
            nA[max(0, i-A[i])] += 1
            nA[min(n, i+1+A[i])] -= 1
        for i in range(1, n+1): nA[i] += nA[i-1]
        A = nA
    print(*A[:-1])

    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n, k = ZZ()
    A = ZZ()+[0]

    for _ in range(k):
        if all([A[i] >= n for i in range(n)]): break
        nA = [0] * (n+1)
        for i in range(n):
            nA[max(0, i-A[i])] += 1
            nA[min(n, i+1+A[i])] -= 1
        for i in range(1, n+1): nA[i] += nA[i-1]
        A = nA
    print(*A[:-1])

    return

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

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

for i in list(set(a)):
    count_of_i = a.count(i)
    if count_of_i < i:
        ans += count_of_i
    else:
        ans += count_of_i - i
print(ans)


### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
ans = 0
counter = Counter(a)
for i in set(a):
    if counter[i] < i:
        ans += counter[i]
    else:
        ans += counter[i] - i
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H.sort()

print(min(map(lambda x: x[-1] - x[0], [H[i:i + K] for i in range(len(H)) if len(H[i:i + K]) == K])))


### FIXED CODE ###

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H.sort()

print(min((H[i + K - 1] - H[i] for i in range(N - K + 1))))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from math import factorial


MOD = 1000000007  # type: int
def cmb(n, r):
    return (factorial(n) // (factorial(r) * factorial(n - r))%MOD)

def solve(S: str):
    S = S[::-1]
    dp = [[0] * 13 for _ in range(len(S))]
    s = S[0]
    if s == "?":
        for i in range(10):
            dp[0][i] = 1
    else:
        dp[0][int(s)] = 1
    # dp[LENGTH][MOD]
    for l in range(1, len(S)):
        s = S[l]
        if s == "?":
            for m in range(13):
                for i in range(10):
                    dp[l][(m + pow(10, l, 13) * i) % 13] += dp[l-1][m]% MOD
        else:
            i = int(s)
            for m in range(13):
                dp[l][(m + pow(10, l, 13) * i) % 13] += dp[l-1][m] % MOD

    # print(dp)
    print(dp[-1][5]% MOD)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# from math import factorial


MOD = 1000000007  # type: int
# def cmb(n, r):
#     return (factorial(n) // (factorial(r) * factorial(n - r))%MOD)

def solve(S: str):
    S = S[::-1]
    dp = [[0] * 13 for _ in range(len(S))]
    # dp[LENGTH][MOD]

    s = S[0]
    if s == "?":
        for i in range(10):
            dp[0][i] = 1
    else:
        dp[0][int(s)] = 1
    for l in range(1, len(S)):
        s = S[l]
        pow_l = pow(10, l, 13)
        if s == "?":
            for m in range(13):
                for i in range(10):
                    dp[l][(m + pow_l * i) % 13] += dp[l-1][m]% MOD
        else:
            i = int(s)
            for m in range(13):
                dp[l][(m + pow_l * i) % 13] += dp[l-1][m] % MOD

    # print(dp)
    print(dp[-1][5]% MOD)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

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

n,k=map(int,input().split())
s=[]
for i in range(n):
  a,b=map(int,input().split())
  s+=[a]*b
p=sorted(s)
print(p[k-1])

### FIXED CODE ###

n,k=map(int,input().split())
d=[0]*(10**5+1)
for i in range(n):
  a,b=map(int,input().split())
  d[a]+=b
for i in range(10**5+1):
  if d[i]>=k:
    print(i)
    break
  else:k-=d[i]
### BUGGY CODE ###

n, mw = map(int, input().split())
w = []
v = []

for i in range(n):
    ww, vv = map(int, input().split())
    w.append(ww)
    v.append(vv)

dp = [0] * (mw + 1)
for i in range(n):
    for j in range(mw, w[i] - 1, -1):
        dp[j] = max(dp[j], dp[j - w[i]] + v[i])

print(dp[mw])

### FIXED CODE ###

n, mw = map(int, input().split())
w = []
v = []

for i in range(n):
    ww, vv = map(int, input().split())
    w.append(ww)
    v.append(vv)

dp = [[0] * (mw + 1) for i in range(n + 1)]

for i in range(n):
    for j in range(mw + 1):
        if j < w[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])

print(dp[n][mw])
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=1
way=0
for i in A:
    ans*=i
way=str(ans-1)
if(len(way)>=19):
    ans=-1
else:
    pass
print(ans)

### FIXED CODE ###

def quick_sort(list):
    stand=list[0]
    over=[]
    same=[]
    under=[]
    for i in list:
        if(i>stand):
            over.append(i)
        elif(i<stand):
            under.append(i)
        else:
            same.append(i)
    if(len(over)>1):
        over=quick_sort(over)
    else:
        pass
    if(len(under)>1):
        under=quick_sort(under)
    else:
        pass

    return under+same+over

N=int(input())
A=list(map(int,input().split()))
A=quick_sort(A)
ans=1
way=0
for i in A:
    ans*=i
    way=str(ans-1)
    if(len(way)>=19):
        ans=-1
        break
    else:
        pass
print(ans)
### BUGGY CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
nA=[a for a in A if a<0]
zero=[a for a in A if a==0]
pA=[a for a in A if a>0]
nA.sort(reverse=True)
pA.sort()

#積がx以下になる組み合わせの数
def f(x):
    ret=0
    if x<0:
        for na in nA:
            ret+=g2(pA,na,x)
        for pa in pA:
            ret+=g2(nA,pa,x)
    elif x==0:
        ret+=len(nA)*len(pA)*2
        ret+=len(zero)*(N-len(zero)+N-1)
    else:
        ret+=len(nA)*len(pA)*2
        ret+=len(zero)*(N-len(zero)+N-1)
        for na in nA:
            ret+=g1(nA,na,x)-(1 if na*na<=x else 0)
        for pa in pA:
            ret+=g1(pA,pa,x)-(1 if pa*pa<=x else 0)
    return ret//2

#単調増加の場合の組み合わせ数
def g1(L,n,x):
    if len(L)==0: return 0
    if L[0]*n>x: return 0
    l=0
    over=len(L)
    while over-l>1:
        m=(over+l)//2
        if L[m]*n<=x: l=m
        else: over=m
    return l+1

#単調減少の場合の組み合わせ数
def g2(L,n,x):
    if len(L)==0: return 0
    if L[-1]*n>x: return 0
    under=-1
    r=len(L)-1
    while r-under>1:
        m=(under+r)//2
        if L[m]*n<=x: r=m
        else: under=m
    return len(L)-r

#組み合わせがK個未満になる最大のxを求める(l)
l=-10**19
r=10**19
while r-l>1:
    m=(r+l)//2
    if f(m)<K: l=m
    else: r=m
print(r)


### FIXED CODE ###

import sys
input = sys.stdin.readline
N,K=map(int,input().split())
A=list(map(int,input().split()))
nA=[a for a in A if a<0]
zero=[a for a in A if a==0]
pA=[a for a in A if a>0]
nA.sort(reverse=True)
pA.sort()

pR=0
neg=len(nA)*len(pA)*2
zzz=len(zero)*(N-len(zero)+N-1)

#積がx以下になる組み合わせの数
def f(x):
    global pR
    ret=0
    if x<0:
        pR=len(pA)-1
        for na in nA:
            while pR>=0:
                if na*pA[pR]>x: break
                pR-=1
            ret+=len(pA)-pR-1
    elif x==0:
        ret+=neg
        ret+=zzz
        ret//=2
    else:
        ret+=neg
        ret+=zzz
        pR=len(nA)-1
        for na in nA:
            while pR>=0:
                if na*nA[pR]<=x: break
                pR-=1
            ret+=pR+1
            ret-=1 if na*na<=x else 0
        pR=len(pA)-1
        for pa in pA:
            while pR>=0:
                if pa*pA[pR]<=x: break
                pR-=1
            ret+=pR+1
            ret-=1 if pa*pa<=x else 0
        ret//=2
    return ret
#組み合わせがK個未満になる最大のxを求める(l)
l=-10**18-1
r=10**18
while r-l>1:
    m=(r+l)//2
    if f(m)<K: l=m
    else: r=m
print(r)
### BUGGY CODE ###

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

num = [A.count(A[i]) + A.count(A[i]-1) + A.count(A[i]+1) for i in range(N)]
print(max(num))

### FIXED CODE ###

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

maximum = max(A)
count = [0]*(maximum + 2)

for i in range(N):
    if A[i] == 0:
        count[0] += 1
        count[1] += 1
        
    elif A[i] == maximum:
        count[A[i]] += 1
        count[A[i] - 1] += 1
    
    else:
        count[A[i] + 1] += 1
        count[A[i]] += 1
        count[A[i] - 1] += 1

print(max(count))
### BUGGY CODE ###


l, r = map(int, input().split())

m = 2019
mod_min = m

for j in range(l,r+1,1):
    j_ = j % m
    for i in range(l,j,1):
        i_ = i % m
        i_j = (i_ * j_) % m
        
        if i_j < mod_min:
            mod_min = i_j
            
print(mod_min)

### FIXED CODE ###

l, r = map(int, input().split())

m = 2019
mod_min = m

is_return = False

for j in range(l,r+1,1):
    #j_ = j % m
    #if j_ == 0:
        #break
        
    if is_return:
        break
    for i in range(l,j,1):
        #i_ = i % m
        i_j = (i * j) % m
        
        if i_j < mod_min:
            mod_min = i_j
            
        if i_j == 0:
            is_return = True
            break
            
print(mod_min)
### BUGGY CODE ###

import math

S = int(input())

ans = [0, 0]
seki = S + 10 ** 6
for i in range(1, 10**9):
    div = seki % i
    if div == 0:
        if seki // i > 10 ** 9:
            continue
        ans += [i, 1, 10 ** 6, seki // i]
        print(*ans)
        exit()


### FIXED CODE ###

import math

S = int(input())

ans = [0, 0]
if S <= 10 ** 9:
    ans += [S, 0, 0, 1]
else:
    root = math.ceil(math.sqrt(S))
    ans += [root ** 2 - S, root, root, 1]

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

N = int(input())
A = list(map(int,input().split()))
count = 0
k=0

while True:
    if A[k] == k+1:
            k += 1
    else:
            count += 1
            A.pop(k)
    if k == len(A):
        break
if count == N:
    print(-1)
else:
    print(count)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)
### BUGGY CODE ###

S = input()


def reverse(rep, target):
    for i in range(0, len(target)):
        if target[i] == rep:
            break
        target = target[:i] + rep + target[i + 1:]
    return target


cnt = 0

while not len(S) == S.count('W') and not len(S) == S.count('B'):
    if S[0] == 'B':
        S = reverse('W', S)
        S = 'W' + S
    else:
        S = reverse('B', S)
        S = 'B' + S

    cnt += 1

print(cnt)


### FIXED CODE ###

S = input()

cnt = 0
for i in range(1, len(S)):
    if not S[i - 1] == S[i]:
        cnt += 1
print(cnt)
### BUGGY CODE ###

H,W = map(int,input().split())
Ch, Cw = map(lambda x: int(x)-1,input().split())
Dh, Dw = map(lambda x: int(x)-1,input().split())
S = []
for i in range(H):
  S.append(input())


from collections import deque

def bfs(sh,sw):
  queue = deque([(sh,sw)])
  d = [[None]*W for _ in range(H)]
  now = set()
  d[sh][sw]=0
  
  while queue:
    h,w = queue.popleft()
    now.add((h,w))
    for nh,nw in [(h-1,w),(h+1,w),(h,w-1),(h,w+1)]:
      if (0<=nh<=H-1 and 0<=nw<=W-1 and S[nh][nw] == '.' and d[nh][nw] is None) == False: continue
      queue.append((nh,nw))
      now.add((nh,nw))
      d[nh][nw]=d[h][w]

    if queue: continue
    for h,w in now:
      for i in range(-2,3):
        for j in range(-2,3):
          if i==0 and abs(j)<=1: continue
          if j == 0 and abs(i)<=1: continue
          nh,nw = h-i,w-j
          if (0<=nh<=H-1 and 0<=nw<=W-1 and S[nh][nw] == '.' and d[nh][nw] is None) == False: continue
          d[nh][nw] = d[h][w]+1
          queue.append((nh,nw))
    now = set()
    #print(queue)
  return d

d = bfs(Ch,Cw)
if d[Dh][Dw] == None: 
  print(-1)
  exit()
print(d[Dh][Dw])

### FIXED CODE ###

H,W = map(int,input().split())
Ch, Cw = map(lambda x: int(x)-1,input().split())
Dh, Dw = map(lambda x: int(x)-1,input().split())
S = []
for i in range(H):
  S.append(input())


from collections import deque

def bfs(sh,sw):
  queue = deque([(sh,sw)])
  d = [[None]*W for _ in range(H)]
  now = set()
  d[sh][sw]=0
  
  while queue:
    h,w = queue.popleft()
    now.add((h,w))
    for nh,nw in [(h-1,w),(h+1,w),(h,w-1),(h,w+1)]:
      if (0<=nh<=H-1 and 0<=nw<=W-1 and S[nh][nw] == '.' and d[nh][nw] is None) == False: continue
      queue.append((nh,nw))
      now.add((nh,nw))
      d[nh][nw]=d[h][w]

    if queue: continue
    for h,w in now:
      for i in range(-2,3):
        for j in range(-2,3):
          if i==0 and abs(j)<=1: continue
          if j == 0 and abs(i)<=1: continue
          nh,nw = h-i,w-j
          if (0<=nh<=H-1 and 0<=nw<=W-1 and S[nh][nw] == '.' and d[nh][nw] is None) == False: continue
          d[nh][nw] = d[h][w]+1
          queue.append((nh,nw))
    now = set()
    #print(queue)
  return d

d = bfs(Ch,Cw)
if d[Dh][Dw] == None: 
  print(-1)
  exit()
print(d[Dh][Dw])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(400000)
n,q=map(int,input().split())
ans=[0]*(n+1) #答え
score=[0]*(n+1) #xの総和
g=[[] for _ in range(n+1)] #グラフ
for i in range(n-1):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)
for j in range(q):
    p,x=map(int,input().split())
    score[p]+=x

visited=[0]*(n+1)
def dfs(v):
    visited[v]+=1
    global ans
    ans[v]+=score[v]
    for i in range(len(g[v])):
        ans[g[v][i]]+=ans[v]
        dfs(g[v][i])
dfs(1)
print(" ".join(map(str, ans[1:])))

### FIXED CODE ###

import sys
sys.setrecursionlimit(400000)
n,q=map(int,input().split())
ans=[0]*(n+1) #答え
score=[0]*(n+1) #xの総和
g=[[] for _ in range(n+1)] #グラフ
for i in range(n-1):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)
for j in range(q):
    p,x=map(int,input().split())
    score[p]+=x

visited=[0]*(n+1)
def dfs(v):
    visited[v]+=1
    global ans
    ans[v]+=score[v]
    for i in range(len(g[v])):
        if visited[g[v][i]]==0:
            ans[g[v][i]]+=ans[v]
            dfs(g[v][i])
dfs(1)
print(" ".join(map(str, ans[1:])))
### BUGGY CODE ###

import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
H, W = map(int, readline().split())
S = [0 for i in range(H)]
for i in range(H):
    S[i] = readline().decode().strip()

def bfs(start, goal, H, W):
    visited = [False for _ in range(H * W)]
    import queue
    q = queue.Queue()
    q.put((start[0], start[1], 0))
    while not q.empty():
        (i, j, dist) = q.get()
        if (i, j) == goal:
            return dist
        visited[i * W + j] = True 
        for dy in range(-1, 2):
            for dx in range(-1, 2):
                if dx * dy != 0 or dx == dy:
                    continue
                if i + dy < 0 or i + dy >= H or j + dx < 0 or j + dx >= W:
                    continue
                if S[i + dy][j + dx] == '#':
                    continue
                if visited[(i + dy) * W + j + dx]:
                    continue
                q.put((i + dy, j + dx, dist + 1))
    return -1

ans = 0
for i in range(H * W):
    start = (i // W, i % W)
    if S[start[0]][start[1]] == '#':
        continue
    for j in range(H * W):
        goal = (j // W, j % W)
        if S[goal[0]][goal[1]] == '#':
            continue
        if start == goal:
            continue
        ans = max(ans, bfs(start, goal, H, W))
print(ans)


### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
H, W = map(int, readline().split())
S = [0 for i in range(H)]
for i in range(H):
    S[i] = readline().decode().strip()

from collections import deque
def bfs(start, H, W):
    INF = 10 ** 9
    dist = [INF] * (H * W)
    q = deque([start])
    dist[start[0] * W + start[1]] = 0
    while q:
        (i, j) = q.popleft()
        d = dist[i * W + j]
        for dy in range(-1, 2):
            for dx in range(-1, 2):
                if dx * dy != 0:
                    continue
                if dx == dy:
                    continue
                if i + dy < 0 or i + dy >= H or j + dx < 0 or j + dx >= W:
                    continue
                if S[i + dy][j + dx] == '#':
                    continue
                if dist[(i + dy) * W + j + dx] != INF:
                    continue
                dist[(i + dy) * W + j + dx] = d + 1
                q.append((i + dy, j + dx))
    return max(x for x in dist if x < INF)

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        start = (i, j)
        ans = max(ans, bfs(start, H, W))
print(ans)
### BUGGY CODE ###

# C
N, M = map(int, input().split())
s = list(input())

# Graph
G = dict()
for i in range(1, N+1):
    G[i] = dict()

for _ in range(M):
    a, b = map(int, input().split())
    G[a][b] = 1
    G[b][a] = 1
    
# clean up
go = True
while go:
    go = False
    for i in range(1, N+1):
        if s[i-1] != "C":
            a = 0
            b = 0
            for k in G[i].keys():
                v = s[k-1]
                if v == "A":
                    a += 1
                elif v == "B":
                    b += 1
            if a*b == 0:
                go = True
                s[i-1] = "C"

if "A" in s and "B" in s:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

# C
from collections import deque

N, M = map(int, input().split())
s = list(input())
s_ = []
for c in s:
    s_.append(c)

# Graph
G = dict()
for i in range(1, N+1):
    G[i] = dict()

for _ in range(M):
    a, b = map(int, input().split())
    G[a][b] = 1
    G[b][a] = 1
    
# clean up
queue = deque()
go = True

As = [0]*N
Bs = [0]*N

for i in range(1, N+1):
    if s[i-1] != "C":
        a = 0
        b = 0
        for k in G[i].keys():
            v = s_[k-1]
            if v == "A":
                a += 1
            elif v == "B":
                b += 1
        As[i-1] = a
        Bs[i-1] = b
        if a*b == 0:
            queue.append(i)
            s[i-1] = "C"

while len(queue) > 0:
    j = queue.popleft()
    for i in G[j].keys():
        if s[i-1] != "C":
            if s_[j-1] == "A":
                As[i-1] -= 1
            else:
                Bs[i-1] -= 1
            if As[i-1] * Bs[i-1] == 0:
                queue.append(i)
                s[i-1] = "C"

if "A" in s and "B" in s:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0]=1
for i in range(1,N+1) : 
    for j in range(S + 1) : 
        if(j==0):
            dp[i][j]=2**i
        else:
            dp[i][j]+=2*dp[i-1][j]
            if(j-A[i-1]>=0):
                dp[i][j]+=dp[i-1][j-A[i-1]]
print(dp[N][S]%mod)

### FIXED CODE ###

N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])
### BUGGY CODE ###

N = int(input())
S = input()
s = set([])
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1,N):
            s.add(S[i]+S[j]+S[k])
print(len(s))

### FIXED CODE ###

N = int(input())
S = input()
S1 = set([])
S2 = set([])
S3 = set([])
for i in S:
    for s3 in S2:
        S3.add(s3+i)
    for s2 in S1:
        S2.add(s2+i)
    S1.add(i)
print(len(S3))
### BUGGY CODE ###

import fractions


def solve(N, A):
    max_gcd = 0
    for i in range(N):
        lst = A[0:i]
        lst.extend(A[i + 1: N])
        gcd = lst[0]
        for j in range(1, len(lst)):
            gcd = fractions.gcd(gcd, lst[j])
        if gcd > max_gcd:
            max_gcd = gcd
    return max_gcd


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


### FIXED CODE ###

from fractions import gcd


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

# l[i] := [0, i]の数のGCDメモ
l = [None for _ in range(N)]
l[0] = A[0]
for i in range(1, N):
    l[i] = gcd(l[i - 1], A[i])

# r[i] := [i, N - 1]の数のGCDメモ
r = [None for _ in range(N)]
r[N - 1] = A[N - 1]
for i in reversed(range(N - 1)):
    r[i] = gcd(r[i + 1], A[i])

ans = 0
for i in range(N):
    if i == 0:
        ans = max(ans, r[1])
    elif i == N - 1:
        ans = max(ans, l[N - 2])
    else:
        ans = max(ans, gcd(l[i - 1], r[i + 1]))
print(ans)