CodeEff/ECCO huggingface dataset:
# Original solution
def gcd(x, y):
    if y > x:
        x, y = y, x
    while y:
        x, y = y, x % y
    return x

N=int(eval(input()))
a=list(map(int,input().split()))

l=[0]*N
l[0]=a[0]
for i in range(1,N):
    l[i]=gcd(l[i-1],a[i])

r=[0]*N
r[N-1]=a[N-1]
for i in range(N-2,-1,-1):
    r[i]=gcd(r[i+1],a[i])

ans=max(r[1],l[N-2])
for i in range(1,N-1):
    tmp=gcd(l[i-1],r[i+1])
    ans=max(tmp,ans)

print(ans)

# Optimized solution
def gcd(x, y):
    if y > x:
        x, y = y, x
    while y:
        x, y = y, x % y
    return x

N=int(eval(input()))
a=list(map(int,input().split()))

l=[0]*N
l[0]=a[0]
for i in range(1,N):
    l[i]=gcd(l[i-1],a[i])

r=[0]*N
r[N-1]=a[N-1]
for i in range(N-2,-1,-1):
    r[i]=gcd(r[i+1],a[i])

ans=max(r[1],l[N-2])
for i in range(1,N-1):
    tmp=gcd(l[i-1],r[i+1])
    if tmp>ans: ans=tmp

print(ans)
# Original solution
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a


def cul(n,x):
    l=len(x)
    b=[x[i] for i in range(l)]
    b.pop(n)
    tmp=b[0]
    for i in range(1,l-1):
        tmp=gcd(tmp,b[i])
    return tmp

import sys
import math
p=100
N=int(eval(input()))
a=list(map(int,input().split()))
if N<=p:
    ans=0
    
    for i in range(N):
        tmp=cul(i,a)        
        if tmp>ans: ans=tmp
    print(ans)
    sys.exit()
        
M=a[0]
for i in range(1,p):
    M=gcd(M,a[i])

ans=0


R=a[p]
for i in range(p,N):
    r=gcd(R,a[i])

if r>ans:
    for i in range(p):
        s=gcd(cul(i,a[:p]),R)
        if s>ans: ans=s

print(ans)


# Optimized solution
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a


def cul(n,x):
    l=len(x)
    b=[x[i] for i in range(l)]
    b.pop(n)
    tmp=b[0]
    for i in range(1,l-1):
        tmp=gcd(tmp,b[i])
    return tmp

import sys
import math
p=100
N=int(eval(input()))
a=list(map(int,input().split()))
if N<=p:
    ans=0
    
    for i in range(N):
        tmp=cul(i,a)        
        if tmp>ans: ans=tmp
    print(ans)
    sys.exit()
        
M=a[0]
for i in range(1,p):
    M=gcd(M,a[i])

ans=0
for i in range(p):
    s=gcd(cul(i,a[:p]),a[p])
    if s>ans: ans=s

print(ans)
# Original solution
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a

def cul(n,x):
    l=len(x)
    b=[x[i] for i in range(l)]
    b.pop(n)
    tmp=b[0]
    for i in range(1,l-1):
        tmp=gcd(tmp,b[i])
    return tmp

import sys
p=100
N=int(eval(input()))
a=list(map(int,input().split()))
if N<=p:
    ans=0
    
    for i in range(N):
        tmp=cul(i,a)        
        if tmp>ans: ans=tmp
    print(ans)
    sys.exit()

ans=0
for i in range(p):
    s=cul(i,a[:p])
    if s>ans: ans=s

print(ans)

# Optimized solution
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a

def cul(n,x):
    l=len(x)
    b=[x[i] for i in range(l)]
    b.pop(n)
    tmp=b[0]
    for i in range(1,l-1):
        tmp=gcd(tmp,b[i])
    return tmp

import sys
p=50
N=int(eval(input()))
a=list(map(int,input().split()))
if N<=p:
    ans=0
    
    for i in range(N):
        tmp=cul(i,a)        
        if tmp>ans: ans=tmp
    print(ans)
    sys.exit()

ans=0
for i in range(p):
    s=cul(i,a[:p])
    if s>ans: ans=s

print(ans)
# Original solution
N = int(eval(input()))
nums = [int(i) for i in input().split()]
from functools import reduce
def gcd(a,b):
  while b!=0:
    a, b = b, a%b
  return a
def compute_gcd(numbers):
    return reduce(gcd, numbers)
from copy import copy
gcds = []
for i in range(len(nums)):
    n = copy(nums)
    n.pop(i)
    gcds.append(compute_gcd(n))
print((max(gcds)))

# Optimized solution
N = int(eval(input()))
nums = [int(i) for i in input().split()]
nums_sorted = sorted(list((set(nums))), reverse=True)
def compute_divs(n):
    divs = []
    if n == 1: return [1]
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    divs.append(n)
    return divs
ans = 1
if len(nums_sorted) == 1: ans = nums[0]
else:
    divs1 = compute_divs(nums_sorted[0])
    divs2 = compute_divs(nums_sorted[1])
    divs = sorted(list(set(divs1+divs2)))
    for i in reversed(divs):
        c= 0
        for j in nums:
            if j % i != 0:
                c += 1
                if c == 2:
                    break
        if c <= 1:
            ans = i
            break
print(ans)
# Original solution

def gcd(a, b):
	while b > 0:
		a, b = b, a % b
	return a


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

if N == 2:
  print((max(A)))
else:
  m = -1
  for i in range(N):
    G = 0
    for j in range(0, i):
      G = gcd(G, A[j])
    for j in range(i+1, N):
      G = gcd(G, A[j])

    m = max(m, G)
  print(m)

# Optimized solution

def gcd(a, b):
	while b > 0:
		a, b = b, a % b
	return a


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

if N == 2:
  print((max(A)))
else:

  L = [0 for j in range(N+1)]
  R = [0 for j in range(N+1)]
  
  for j in range(N):
    L[j+1] = gcd(L[j], A[j])
  for j in reversed(list(range(N))):
    R[j] = gcd(R[j+1], A[j])

    m = -1
  for j in range(N):
    m = max(m, gcd(L[j], R[j+1]))
  print(m)
# Original solution
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    tmp = x%y
    while not tmp == 0:
        x = y
        y = tmp
        tmp = x%y
    return y
N = int(eval(input()))
A = list(map(int,input().split()))

gcd_max = 0
for i in range(N):
    tmp = A[0]
    if i == 0:
        tmp = A[1]
    for j in range(N):
        if not j == i:
            tmp = gcd(tmp,A[j])
    if tmp > gcd_max:
        gcd_max = tmp
print(gcd_max)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))

def GCD(x,y):
    while y != 0:
        x,y = y,x%y
    return x

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

ans = 0
for i in range(N):
    ans = max(ans,GCD(l[i],r[N-i-1]))
print(ans)
# Original solution
from functools import reduce

result = 0

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

n = int(eval(input()))
A = list(map(int, input().split()))
for i in range(n):
    result = max(result, reduce(gcd, A[:i]+A[i+1:]))

print(result)

# Optimized solution
from functools import reduce

result = 0

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

n = int(eval(input()))
A = list(map(int, input().split()))
X = [0 for i in range(n)]
Y = [0 for i in range(n)]
for i in range(1, n):
    X[i] = gcd(X[i-1], A[i-1])
for i in range(n-1)[::-1]:
    Y[i] = gcd(Y[i+1], A[i+1])
print((max(gcd(X[i], Y[i]) for i in range(n))))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

def factorize(x):
    """xの素因数分解を表す辞書 {素因数: 指数}"""
    f = {}
    d = 2
    while x > 1:
        c = 0
        while x % d == 0:
            c += 1
            x //= d
        f[d] = c
        d += 1
        if d * d > x > d:
            d = x
    return f

def dropmin(ls):
    """[min(ls[:i] + ls[i + 1:]) for i in range(len(ls))]"""
    # l = [min(ls[:i]) for i in range(len(ls))]
    l = [float('inf')] * len(ls)
    for i in range(1, len(ls)):
        l[i] = min(l[i - 1], ls[i - 1])
    # r = [min(ls[i + 1:]) for i in range(len(ls))]
    r = [float('inf')] * len(ls)
    for i in range(len(ls) - 2, -1, -1):
        r[i] = min(r[i + 1], ls[i + 1])
    return [min(a, b) for a, b in zip(l, r)]

def prod(ls):
    p = 1
    for x in ls:
        p *= x
    return p

# 各A_iの素因数
F = [factorize(a) for a in A]

# 素因数の集合 (2要素に出現しない素因数は無視)
D =  set(F[0].keys())
D.update(list(F[1].keys()))

# Dの要素 d → dが各A_iに含まれる個数のリスト
X = {d: [f[d] if d in f else 0 for f in F] for d in D}

# Dの要素 d → A_iを削除したときのdの個数の最小値のリスト
X = {d: dropmin(X[d]) for d in D}

S = [prod(d ** X[d][i] for d in D if X[d][i] > 0) for i in range(N)]
print((max(S)))


# Optimized solution
# math.gcd is introduced in python 3.5
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a

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

# L[i] = gcd(A[:i + 1])
# R[i] = gcd(A[i:])
L = [0] * N
L[0] = A[0]
for i in range(1, N):
    L[i] = gcd(L[i-1], A[i])
R = [0] * N
R[-1] = A[-1]
for i in range(N - 2, -1, -1):
    R[i] = gcd(R[i+1], A[i])

G = [0] * N
G[0]  = R[1]
G[-1] = L[-2]
for i in range(1, N - 1):
    G[i] = gcd(L[i-1], R[i+1])

print((max(G)))
# Original solution
def gcd(a,b):
  while b:a,b=b,a%b
  return a
n=int(eval(input()))
a=list(map(int,input().split()))
if n==2:print((max(a[0],a[1])));exit()
left=[a[0]]
for i in range(1,n):left.append(gcd(left[-1],a[i]))
right=[a[n-1]]
for i in range(n-2,-1,-1):right.append(gcd(right[-1],a[i]))
right.reverse()
ans=max(right[1],left[n-2])
print((max(ans,max(gcd(left[i-1],right[i+1])for i in range(1,n-1)))))

# Optimized solution
def gcd(a,b):
  while b:a,b=b,a%b
  return a
n,a=int(eval(input())),list(map(int,input().split()))
if n==2:print((max(a)));exit()
if n==3:print((max(gcd(a[0],a[1]),gcd(a[0],a[2]),gcd(a[1],a[2]))));exit()
ans=ans2=a[0]
for i in range(1,n):
  g=gcd(ans,a[i])
  if g!=ans:
    ans=max(g,ans2)
    ans2=gcd(g,ans2)
print(ans)
# Original solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

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

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

result = []
for skip in range(0, N):
    l = 0
    r = 0
    for i in range(0, skip):
        l = GCD(l, A[i])
    for i in range(skip+1, N):
        r = GCD(r, A[i])
    n = GCD(l, r)
#   print(l,r,n)
    result.append(n)
print(max(result))


# Optimized solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

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

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()


l_list = []
l = 0
for i in range(0, N):
    l = GCD(l, A[i])
    l_list.append( l )

r_list = []
r = 0
for i in range(-1, -(N+1), -1):
    r = GCD(r, A[i])
    r_list.append( r )

n = []    
for i in range(0, N):
    if i-1 < 0:
        l = 0
    else:
        l = l_list[i-1]
    if N-i-2 < 0:
        r = 0
    else:
        r = r_list[N-i-2]
    n.append(GCD(l, r))
print(max(n))
# Original solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

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

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()


l_list = []
l = 0
for i in range(0, N):
    l = GCD(l, A[i])
    l_list.append( l )

r_list = []
r = 0
for i in range(-1, -(N+1), -1):
    r = GCD(r, A[i])
    r_list.append( r )

n = []    
for i in range(0, N):
    if i-1 < 0:
        l = 0
    else:
        l = l_list[i-1]
    if N-i-2 < 0:
        r = 0
    else:
        r = r_list[N-i-2]
    n.append(GCD(l, r))
print(max(n))


# Optimized solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

N = int(input())
A = [ int(v) for v in input().split() ]
AR = list(reversed(A))

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

l_list = [0]
for i in range(0, N):
    l = GCD(l_list[i], A[i])
    l_list.append( l )

r_list = [0]
for i in range(0, N):
    r = GCD(r_list[i], AR[i])
    r_list.append( r )

n = []
j = -2   
for i in range(0, N):
    l = l_list[i]
    r = r_list[j]
    n.append(GCD(l, r))
    j -= 1
print(max(n))
# Original solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

N = int(input())
A = [ int(v) for v in input().split() ]
AR = list(reversed(A))

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

l_list = [0]
for i in range(0, N):
    l = GCD(l_list[i], A[i])
    l_list.append( l )

r_list = [0]
for i in range(0, N):
    r = GCD(r_list[i], AR[i])
    r_list.append( r )

n = []
j = -2   
for i in range(0, N):
    l = l_list[i]
    r = r_list[j]
    n.append(GCD(l, r))
    j -= 1
print(max(n))


# Optimized solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

N = int(input())
A = [ int(v) for v in input().split() ]
AR = list(reversed(A))

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

l_list = [0]
r_list = [0]
for i in range(0, N):
    l_list.append( GCD(l_list[i],  A[i]) )
    r_list.append( GCD(r_list[i], AR[i]) )

n = []
j = -2   
for i in range(0, N):
    l = l_list[i]
    r = r_list[j]
    n.append(GCD(l, r))
    j -= 1
print(max(n))
# Original solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

N = int(input())
A = [ int(v) for v in input().split() ]
AR = list(reversed(A))

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

l_list = [0]
r_list = [0]
for i in range(0, N):
    l_list.append( GCD(l_list[i],  A[i]) )
    r_list.append( GCD(r_list[i], AR[i]) )

n = []
j = -2   
for i in range(0, N):
    l = l_list[i]
    r = r_list[j]
    n.append(GCD(l, r))
    j -= 1
print(max(n))


# Optimized solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

N = int(input())
A = [ int(v) for v in input().split() ]
AR = list(reversed(A))

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

l_list = [0]
r_list = [0]
for i in range(0, N):
    l_list.append( GCD(l_list[i],  A[i]) )
    r_list.append( GCD(r_list[i], AR[i]) )

n = []
j = -2   
for i in range(0, N):
    n.append(GCD(l_list[i], r_list[j]))
    j -= 1
print(max(n))
# Original solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

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

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

l_list = [0]
r_list = [0]
j = -1
for i in range(0, N):
    l_list.append(    GCD(l_list[i],  A[i]) )
    r_list.insert( 0, GCD(r_list[j],  A[j]) )
    j -= 1
n = []
for i in range(0, N):
    n.append(GCD(l_list[i], r_list[i+1]))
print(max(n))


# Optimized solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b
     
N = int(input())
A = [ int(v) for v in input().split() ]
    
if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()
     
l_list = [0]
r_list = [0]
j = -1
for i in range(0, N):
    l_list.append( GCD(l_list[i],  A[i]) )
    r_list.append( GCD(r_list[i],  A[j]) )
    j -= 1
n = []
j = -2   
for i in range(0, N):
    n.append(GCD(l_list[i], r_list[j]))
    j -= 1
print(max(n))
# Original solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b
     
N = int(input())
A = [ int(v) for v in input().split() ]
    
if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()
     
l_list = [0]
r_list = [0]
j = -1
for i in range(0, N):
    l_list.append( GCD(l_list[i],  A[i]) )
    r_list.append( GCD(r_list[i],  A[j]) )
    j -= 1
n = []
j = -2   
for i in range(0, N):
    n.append(GCD(l_list[i], r_list[j]))
    j -= 1
print(max(n))


# Optimized solution
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b
     
N = int(input())
A = [ int(v) for v in input().split() ]
    
if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()
     
l_list = [0]
r_list = [0]
j = -1
for i in range(0, N):
    l_list.append( GCD(l_list[i],  A[i]) )
    r_list.append( GCD(r_list[i],  A[j]) )
    j -= 1

j = -2
mymax = 1   
for i in range(0, N):
    tmp = GCD(l_list[i], r_list[j])
    if tmp > mymax: mymax = tmp 
    j -= 1
print(mymax)
# Original solution
from collections import Counter as c
m=int(eval(input()))
a=list(map(int,input().split()))

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)

  divisors.sort()
  return divisors

arr=[]
for i in a:
  arr+=make_divisors(i)

commonarr=c(arr).most_common()
ans=0
for i in commonarr:
  if i[1]>=m-1:
    ans=max(ans,i[0])
  else:
    break
print(ans)

# Optimized solution
n=int(eval(input()))
a=sorted(list(map(int,input().split())))
i=a[1]
while i > 0:
  flg=0
  for j in a:
    if j%i!=0:
      flg+=1
      if flg>1:
        break
  if flg<=1:
    print(i)
    break
  else:
    i-=1
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

ans = 0
L = [0]
R = [0]
for i in range(n-1):
    l = gcd(L[-1], A[i])
    L.append(l)
    r = gcd(R[-1], A[::-1][i])
    R.append(r)
for l, r in zip(L,R[::-1]):
    ans = max(ans, gcd(l, r))
print(ans)

# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

ans = 0
L = [0]*(n)
R = [0]*(n+1)
for i in range(n-1):
    L[i+1] = gcd(L[i], A[i])
    R[i+1] = gcd(R[i], A[-i-1])
for l, r in zip(L[::-1],R):
    ans = max(ans, gcd(l, r))
print(ans)
# Original solution

n = int(eval(input()))
a = [int(m) for m in input().split()]
a.sort()
m0 = a[0]
m1 = a[1]
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)

    # divisors.sort()
    return divisors



mm0 = make_divisors(m0)
mm1 = make_divisors(m1)
mm = mm0 + mm1
mm.sort()
si = 0
candi = 0
for g in mm:
    si = 0
    for i in range(n):
        if a[i] % g != 0:
            si += 1
            if si == 2:
                break
    else:
        candi = g
print(candi)

# Optimized solution
import sys
# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
# from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
# from itertools import permutations, combinations, product, accumulate, groupby
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
# inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []; mod = 10 ** 9 + 7
# dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return eval(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n = i()
a = wi()
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b)

l_gcd = [a[0]]#左から
r_gcd = [a[-1]]#右から
kl = a[0]
kr = a[-1]
for i in range(n - 2):
    kl = gcd(kl, a[i + 1])
    l_gcd.append(kl)
    kr = gcd(kr, a[-(i + 2)])
    r_gcd.append(kr)

ansli = []
for i in range(n):
    if i == 0:
        ansli.append(r_gcd[-1])
    elif i == n - 1:
        ansli.append(l_gcd[-1])
    else:
        ansli.append(gcd(l_gcd[i - 1], r_gcd[-(i + 1)]))

print((max(ansli)))
# Original solution
n = int(eval(input()))
num_list = list(map(int, input().split()))
num_list.sort()
num_list.reverse()
answer_list = []
max_num = 0
flag = False
for i in range(num_list[0], 0, -1):
    if flag and count < 2:
        break
    else:
        flag = True
        count = 0
        max_num = i
    for j in range(n):
        if num_list[j] / max_num < 1 or num_list[j] % max_num != 0:
            count += 1
            if count > 1:
                break
print(max_num)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
end = sorted(a)[1]

for i in range(end + 1, 0, -1):
    x = 0
    for j in a:
        if j % i != 0:
            x += 1
        if x >= 2:
            break
    if x <= 1:
        print(i)
        break
# Original solution
n = int(eval(input()))
A = list(map(int,input().split()))

ass = set()
def div(x):
    for i in range(1,int(x**0.5)+1):
        if x%i == 0:
            ass.add(i)
            ass.add(x//i)
    return ass

a0 = A[0]
a1 = A[1]
div(a0)
div(a1)
ans = []
for i in ass:
    cnt = 0
    for a in A:
        if a%i == 0:
            cnt += 1
    if cnt >= n-1:
        ans.append(i)
print((max(ans)))


# Optimized solution
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7

n = int(eval(input()))
A = list(map(int,input().split()))
ass = set()
def div(x):
    for i in range(1,int(x**0.5)+1):
        if x%i == 0:
            ass.add(i)
            ass.add(x//i)
    return ass
a0 = A[0]
a1 = A[1]
div(a0)
div(a1)
ans = 1
for i in ass:
    cnt = 0
    for a in A:
        if a%i == 0:
            cnt += 1
    if cnt >= n-1:
        ans = max(ans,i)
print(ans)
# Original solution
import sys
input = sys.stdin.readline
 
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a
#nの約数列挙
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass #sortされていない
 
#0番目を使わない場合
res = gcdlist(a[1::])
 
#else
p = sorted(divisor(a[0]))
for i in range(len(p)-1,-1,-1):
    if p[i]<=res:
        break
    cnt = 1
    for j in range(1,n):
        if a[j]%p[i]==0:
            cnt += 1
    if cnt >= n-1:
        res = p[i]
        break
print(res)

# Optimized solution
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

#b[i]:a[0]~a[i]までのgcd,c[i]:a[i]~a[-1]までのgcd
b = [0]*n
c = [0]*n
for i in range(n):
    if i == 0:
        b[0] = a[0]
        c[-1] = a[-1]
        continue
    b[i]=gcd(b[i-1],a[i])
    c[n-1-i]=gcd(c[n-i],a[n-1-i])

res = max(b[n-2],c[1])
for i in range(1,n-1):
    res = max(res,gcd(b[i-1],c[i+1]))
print(res)