CodeEff/ECCO huggingface dataset:
# Original solution
import math
n=int(eval(input()))
a=list(map(int,input().split()))

a.sort()
g=a[0]

for i in range(1,n):
  g=math.gcd(g,a[i])

d=[set(),set()]
for i in range(2):
  b=a[i]//g
  f=1
  while f*f<b+1:
    if b%f==0:
      d[i].add(f)
      d[i].add(b//f)
    f+=1

an=d[0]&d[1]
xo=d[0]^d[1]

for i in range(2,n):
  e1=set()
  e2=set()
  for m in xo:
    if a[i]%m!=0:
      e1.add(m)
  for m in an:
    if a[i]%m!=0:
      e2.add(m)
      xo.add(m)
  for m in e1:
    xo.remove(m)
  for m in e2:
    an.remove(m)
an.add(0)
xo.add(0)
print((max(max(xo),max(an))*g))
    

# Optimized solution
import math
n=int(eval(input()))
a=list(map(int,input().split()))

a.sort()
g=a[0]

for i in range(1,n):
  g=math.gcd(g,a[i])

d=[set(),set()]
for i in range(2):
  b=a[i]//g
  f=1
  while f*f<b+1:
    if b%f==0:
      d[i].add(f)
      d[i].add(b//f)
    f+=1

an=d[0]&d[1]
an.remove(1)
xo=d[0]^d[1]

for i in range(2,n):
  e1=set()
  e2=set()
  for m in xo:
    if a[i]%m!=0:
      e1.add(m)
  for m in an:
    if a[i]%m!=0:
      e2.add(m)
      xo.add(m)
  for m in e1:
    xo.remove(m)
  for m in e2:
    an.remove(m)
an.add(1)
xo.add(1)
print((max(max(xo),max(an))*g))
# Original solution
N = int(eval(input()))
A = [int(x) for x in input().split()]


def max_GCD(m_list):
  m_list.sort()
  a = m_list.pop()
  result = a
  while m_list:
    b = m_list.pop()
    a = GCD(a, b)
    if a < result:
      result = a
    if result == 1:
      return result
  return result

def GCD(m, n):
  a = max(m, n)
  b = min(m, n)
  while b > 0:
    r = a % b
    if r == 0:
      return b
    a = b
    b = r  

r_list = [0] * N
for i in range(N):
  A_ = A.copy()
  A_.pop(i)
  r_list[i] = max_GCD(A_)
  
print((max(r_list)))

# Optimized solution
N = int(eval(input()))
A = [int(x) for x in input().split()]

def GCD(m, n):
  if m == 0:
    return n
  elif n == 0:
    return m
  a = max(m, n)
  b = min(m, n)
  while b > 0:
    r = a % b
    if r == 0:
      return b
    a = b
    b = r  

L = [0] * (N + 1)
R = [0] * (N + 1)
for i in range(N):
  L[i + 1] = GCD(L[i], A[i])
  R[N - i - 1] = GCD(R[N - i], A[N - i - 1])
M = [GCD(L[i], R[i+1]) for i in range(N)]
print((max(M)))
# Original solution
def check(ary, div):
    c = 0
    for i in range(len(ary)):
        if ary[i] % div == 0:
            c += 1
    if c >= len(ary) - 1:
        return True
    else:
        return False
 
N = int(eval(input()))
data = list(map(int, input().split()))
ans = 1
for i in range(1, max(data) + 1)[::-1]:
    if check(data, i):
        ans = i
        break
 
print(ans)


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

def gcd(a, b):
    while b:
        a, b = b, a % b
        # print("a b", a, b)
    return a

left_ = [0] * (n + 1)
right_ = [0] * (n + 1)
ans = []

for i in range(n):
    left_[i] = gcd( left_[i-1], data[i] )

for i in range(n-1, 0, -1):
    right_[i] = gcd( right_[i+1], data[i] )

for i in range(n):
    ans += [ gcd( left_[i-1], right_[i+1] ) ]

print(( max(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()))
L = [0]
R = [0]
ans = 0
for i in range(N):
	L.append(gcd(L[i],A[i]))
	R.insert(0,gcd(R[0],A[N-1-i]))
L.append(0)
R.insert(0,0)
for i in range(N):
	ans = max(ans,(gcd(L[i], R[i+2])))
print(ans)

# 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()))
L = [0]*(N+2)
R = [0]*(N+2)
ans = 0
for i in range(N):
	L[i+1] = (gcd(L[i],A[i]))
	R[N-i] = (gcd(R[N-i+1],A[N-1-i]))
for i in range(N):
	ans = max(ans,(gcd(L[i], R[i+2])))
print(ans)
# Original solution
from functools import reduce
N = int(eval(input()))
A=sorted(list(map(int,input().split())))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def gcdlist(lista):
    if len(lista) == 1:
        return lista[0]
    else:
        from functools import reduce
        return reduce(gcd,lista)
ans = []
ans.append(gcdlist(A[1:]))
ans.append(gcdlist(A[:-1]))
for i in range(1,N-1):
    ans.append(gcd(gcdlist(A[:i]),gcdlist(A[i+1:])))
print((max(ans)))

# Optimized solution
N = int(eval(input()))
A=sorted(list(map(int,input().split())))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
ans = []
gcdlist = [A[0]]
for i in range(1,N):
    gcdlist.append(gcd(gcdlist[i-1],A[i]))
gcdlistr = [A[-1]]
for i in range(N-2,-1,-1):
    gcdlistr.append(gcd(gcdlistr[N-i-2],A[i]))
gcdlistr.reverse()
gcdlist.insert(0,0)
gcdlist.append(0)
gcdlistr.insert(0,0)
gcdlistr.append(0)
for i in range(N):
    ans.append(gcd(gcdlist[i],gcdlistr[i+2]))
print((max(ans)))
# Original solution
n = int(eval(input()))
As = 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)
    return divisors

# 1個目と2個目の約数列挙
# ⇨ 1個しか消さないから必ずどちらかの約数は残る
divs = make_divisors(As[0]) + make_divisors(As[1])
divs = list(set(divs))
cnt = 1

for div in sorted(divs,reverse=True):
    a = sum([1 for a in As if a%div == 0])
    if n - a <= 1:
        print(div)
        exit()

# Optimized solution
n = int(eval(input()))
As = list(map(int, input().split()))
# from math import gcd
def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a
# 左からの累積GCDと
g = As[0]
left = []
for a in As:
    g = gcd(g, a)
    left.append(g)
# 右からの累積GCD
As_r = As[::-1]
g_r = As_r[0]
right = []    
for a in As_r:
    g_r = gcd(g_r, a)
    right.append(g_r)
    
l = left
r = right[::-1]
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:     
        g = gcd(l[i-1],r[i+1])
        ans = max(ans, g)
print(ans)
# Original solution
from collections import defaultdict
n = int(eval(input()))
a = list(map(int,input().split()))
d = defaultdict(int)
for ai in a:
   for i in range(1,int(ai**0.5)+1):
    if ai%i==0:
        d[i] += 1
        if i!=ai//i:
            d[ai//i] += 1

sd=sorted(list(d.items()),key=lambda x:x[0],reverse=True)
for k,v in sd:
    if v==n or v==n-1:
        print(k)
        break

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

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


if n == 2:
    print((max(a)))
else:
    cand = []
    for j in range(n):
        if j == 0:
            temp = a[1]
            for i in range(2,len(a)):
                temp = gcd(temp, a[i])
        else:
            temp = a[0]
            for i in range(1,len(a)):
                if i != j:
                    temp = gcd(temp, a[i])
        cand.append(temp)
    print((max(cand)))


# Optimized solution
# -*- coding: utf-8 -*-

n = 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

if n == 2:
    print((max(a)))
else:
    list1 = make_divisors(a[0])
    list2 = make_divisors(a[1])
    list1.sort()
    list2.sort()
    flag1 = 0
    cand1 = 0
    for i in range(len(list1)):
        flag1 = 0
        for j in range(n):
            if a[j] % list1[i] != 0:
                flag1 += 1
        if flag1 <= 1:
            cand1 = list1[i]
    cand2 = 0
    for i in range(len(list2)):
        flag2 = 0
        for j in range(n):
            if a[j] % list2[i] != 0:
                flag2 += 1
        if flag2 <= 1:
            cand2 = list2[i]
    print((max(cand1,cand2)))
# Original solution
def gcdf(a):
    a.sort()
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 

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

if n==2:
    print((max(a)))
elif n<2**8:
    gcdv=0
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        gcdx=gcdf(acpy)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)
else:
    m=int(n/10)
    ns=int(n/m)
    rgcd=[]
    for mi in range(m):
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
        gcdm=gcdf(am)
        rgcd.append(gcdm)
    gcdv=0

    for mi in range(m):
        rgcd1=list(rgcd)
        del rgcd1[mi]
        gcdrg1=gcdf(rgcd1)
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
#        print(mi,gcdf(am),len(am),gcdf(rgcd1))
        for i in range(len(am)):
            acpy=list(am)
#            del acpy[i]
#            acpy.append(gcdrg1)
            acpy[i]=gcdrg1
            gcdx=gcdf(acpy)
            if gcdx>gcdv:
                gcdv=gcdx
    print(gcdv)


# Optimized solution
def gcdf(a):
    a.sort()
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 

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

if n==2:
    print((max(a)))
elif n<2**8:
    gcdv=0
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        gcdx=gcdf(acpy)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)
else:
    m=int(n/100)
    ns=int(n/m)
    rgcd=[]
    for mi in range(m):
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
        gcdm=gcdf(am)
        rgcd.append(gcdm)
    gcdv=0

    for mi in range(m):
        rgcd1=list(rgcd)
        del rgcd1[mi]
        gcdrg1=gcdf(rgcd1)
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
#        print(mi,gcdf(am),len(am),gcdf(rgcd1))
        for i in range(len(am)):
            acpy=list(am)
#            del acpy[i]
#            acpy.append(gcdrg1)
            acpy[i]=gcdrg1
            gcdx=gcdf(acpy)
            if gcdx>gcdv:
                gcdv=gcdx
    print(gcdv)
# Original solution
N = int(eval(input()))

A_list = list(map(int, input().split())) # case1 : [7, 6, 8]

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

ans = 0

for i in range(N):
    left_gcd = 0
    right_gcd = 0

    for j in range(0, i):
        left_gcd = gcd(A_list[j], left_gcd)

    for k in range(i+1, N):
        right_gcd = gcd(A_list[k], right_gcd)

    i_gcd = gcd(left_gcd, right_gcd)

    if ans < i_gcd:
        ans = i_gcd

print(ans)

# Optimized solution
N = int(eval(input()))

A_list = list(map(int, input().split())) # case1 : [7, 6, 8]

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

left_gcd = [0] * (N+1)
right_gcd = [0] * (N+1)
for i in range(N):
    left_gcd[i+1] = gcd(A_list[i], left_gcd[i])
for i in range(N-1, 0, -1):
    right_gcd[i] = gcd(A_list[i], right_gcd[i+1])

ans = 0

for i in range(N):
    i_gcd = gcd(left_gcd[i], right_gcd[i+1])
    if ans < i_gcd:
        ans = i_gcd

print(ans)
# Original solution
n = int(eval(input()))


import math
from functools import reduce
def gcd(numbers):
  return reduce (math.gcd, numbers)


ans = 0
a = list(map(int, input().split()))
for i in range(n):
  c = a[i]
  a.remove(c)
  ans = max(ans, gcd(a))
  a.insert(i, c)
#print(a)
  

print(ans)

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

import math
l_gcd = []
r_gcd = []

c = a[0]
for i in a[:-1]:
  c = math.gcd(c, i)
  l_gcd.append(c)
  
c = a[-1]
for j in a[1:][::-1]:
  c = math.gcd(c, j)
  r_gcd.append(c)
  
ans = max(r_gcd[-1], l_gcd[-1])
for r, l in zip(r_gcd[:-1], l_gcd[:-1][::-1]):
  c = math.gcd(r, l)
  ans = max(ans, c)
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

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

def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a


dp = [a[0]]*(n)
dp[0] = a[1]
ldp = len(dp)
for i in range(1, n):
    a1 = a[i]
    ji = 0
    g1 = 0
    for j in range(ldp):
        if dp[j] == 1 or j == i: continue
        if j > i and ji == 0:
            if g1 == 0:
                g1 = gcd(a1, dp[j])
                ji = 1
                dp[j] = g1
                g1 = 1
            else:
                dp[j] = g1
        else:
            dp[j] = gcd(a1, dp[j])

print((max(dp)))


# Optimized solution

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

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

left = [0] * (n + 1)
for i in range(1, n):
    left[i] = gcd(left[i - 1], a[i - 1])

right = [0] * (n + 1)
for i in range(1, n):
    right[n - i] = gcd(right[n - i + 1], a[n - i])

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i + 1]))
print(ans)
# Original solution
import operator
class SegmentTree:
    def __init__(self, size, default, op = operator.add):
        self.size = 1
        while self.size < size:
            self.size *= 2
        self.dat = [default for i in range(self.size*2-1)]
        self.op = op

    def update(self, i, x):
        i += self.size - 1
        self.dat[i] = x
        while i > 0:
            i = (i - 1) // 2
            self.dat[i] = self.op(self.dat[i*2+1], self.dat[i*2+2])

    def add(self, i, x):
        i += self.size - 1
        self.dat[i] = self.op(self.dat[i], x)
        while i > 0:
            i = (i - 1) // 2
            self.dat[i] = self.op(self.dat[i], x)

    def get(self, a, b, k = None, l = None, r = None):
        if k is None:
            k = 0
            l = 0
            r = self.size

        if r <= a or b <= l:
            return None

        if a <= l and r <= b:
            return self.dat[k]

        res_l = self.get(a, b, k*2+1, l, (l+r)//2)
        res_r = self.get(a, b, k*2+2, (l+r)//2, r)
        if res_l is None:
            return res_r
        if res_r is None:
            return res_l
        return self.op(res_l, res_r)


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

n = int(eval(input()))
a = list(map(int, input().split()))
seg = SegmentTree(n,0,gcd)
for i in range(n):
    seg.update(i,a[i])
ans = 1
for i in range(n):
    seg.update(i,0)
    ans = max(ans, seg.get(0,n))
    seg.update(i,a[i])
print(ans)


# Optimized solution
import operator
class SegmentTree:
    def __init__(self, size, default, op = operator.add):
        self.size = 2**size.bit_length()
        self.dat = [default]*(self.size*2)
        self.op = op

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.op(self.dat[i*2], self.dat[i*2+1])

    def add(self, i, x):
        i += self.size
        self.dat[i] = self.op(self.dat[i], x)
        while i > 0:
            i >>= 1
            self.dat[i] = self.op(self.dat[i], x)

    def get(self, a, b = None):
        if b is None:
            b = a + 1
        l, r = a + self.size, b + self.size
        res = None
        while l < r:
            if l & 1:
                if res is None:
                    res = self.dat[l]
                else:
                    res = self.op(res, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                if res is None:
                    res = self.dat[r]
                else:
                    res = self.op(res, self.dat[r])
            l >>= 1
            r >>= 1

        return res

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

n = int(eval(input()))
a = list(map(int, input().split()))
seg = SegmentTree(n,0,gcd)
for i in range(n):
    seg.update(i,a[i])
ans = 1
for i in range(n):
    seg.update(i,0)
    ans = max(ans, seg.get(0,n))
    seg.update(i,a[i])
print(ans)
# Original solution
def gcd(a, b):
    if a == 0:
        return b
    else:
        return gcd(b%a, a)

class SegmentTree:
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default]*(self.size*2-1)
        self.f = f

    def update(self, i, x):
        i += self.size-1
        self.dat[i] = x
        while i > 0:
            i = (i-1) >> 1
            self.dat[i] = self.f(self.dat[i*2+1], self.dat[i*2+2])

    def query(self, a, b=None, k=0, l=0, r=None):
        if r is None:
            r = self.size
        if b is None:
            b = a + 1
        if r <= a or b <= l:
            return self.default
        if a <= l and r <= b:
            return self.dat[k]
        else:
            lres = self.query(a, b, k*2+1, l, (l+r) >> 1)
            rres = self.query(a, b, k*2+2, (l+r) >> 1, r)
            return self.f(lres, rres)

n = int(eval(input()))
a = list(map(int, input().split()))
s = SegmentTree(n, gcd)
for i in range(n):
    s.update(i,a[i])

ans = 1
for i in range(n):
    left = s.query(0,i)
    right = s.query(i+1,n)
    res = gcd(left, right)
    if ans < res:
        ans = res
print(ans)


# Optimized solution
def gcd(a, b):
    if a == 0:
        return b
    else:
        return gcd(b%a, a)

class SegmentTree:
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default]*(self.size*2)
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, a, b=None):
        if b is None:
            b = a + 1
        l, r = a + self.size, b + self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres)
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res

n = int(eval(input()))
a = list(map(int, input().split()))
s = SegmentTree(n, gcd)
for i in range(n):
    s.update(i,a[i])

ans = 1
for i in range(n):
    left = s.query(0,i)
    right = s.query(i+1,n)
    res = gcd(left, right)
    if ans < res:
        ans = res
print(ans)
# Original solution
class SegmentTree:
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default]*(self.size*2-1)
        self.f = f

    def update(self, i, x):
        i += self.size-1
        self.dat[i] = x
        while i > 0:
            i = (i-1) >> 1
            self.dat[i] = self.f(self.dat[i*2+1], self.dat[i*2+2])

    def query(self, l, r, k=0, L=0, R=None):
        if R is None:
            R = self.size
        if R <= l or r <= L:
            return self.default
        if l <= L and R <= r:
            return self.dat[k]
        else:
            lres = self.query(l, r, k*2+1, L, (L+R) >> 1)
            rres = self.query(l, r, k*2+2, (L+R) >> 1, R)
            return self.f(lres, rres)

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

n = int(eval(input()))
a = list(map(int, input().split()))
s = SegmentTree(n, gcd)
for i in range(n):
    s.update(i, a[i])

ans = 1
for i in range(n):
    left = s.query(0, i)
    right = s.query(i+1, n)
    res = gcd(left, right)
    if ans < res:
        ans = res
print(ans)

# Optimized solution
class SegmentTree:
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default]*(self.size*2)
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres)
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res

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

n = int(eval(input()))
a = list(map(int, input().split()))
s = SegmentTree(n, gcd)
for i in range(n):
    s.update(i, a[i])

ans = 1
for i in range(n):
    left = s.query(0, i)
    right = s.query(i+1, n)
    res = gcd(left, right)
    if ans < res:
        ans = res
print(ans)
# Original solution
# -*- coding: utf-8 -*-

import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd
from functools import reduce

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

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])

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


# Optimized solution
# -*- coding: utf-8 -*-

import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

# 予め左右から累積GCDを取っておく
L=[0]*(N+2)
for i in range(N):
    L[i+1]=gcd(L[i], A[i])
R=[0]*(N+2)
for i in range(N-1, -1, -1):
    R[i+1]=gcd(R[i+2], A[i])

# 1箇所除いてどうなるかを全部試しても、各回GCD1回ずつで済む
ans=0
for i in range(N):
    ans=max(ans, gcd(L[i], R[i+2]))
print(ans)
# Original solution
N = int(eval(input()))
a =list(map(int, input().split()))

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

from functools import reduce
max_val = reduce(gcd, a[1:])
for i in range(1, N):
    tmp = a[i]
    a[i] = a[0]
    val = reduce(gcd, a)
    if max_val < val:
        max_val = val
        
    a[i] = tmp
print(max_val)

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

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

L = []
for i in range(len(a)):
    if i==0:
        L.append(None)
    elif i ==1:
        L.append(a[i-1])
    else:
        L.append(gcd(L[-1], a[i-1]))
        
R = []
for i in range(len(a)):
    if i==0:
        R.append(None)
    elif i ==1:
        R.append(a[-i])
    else:
        R.append(gcd(R[-1], a[-i]))
R = R[::-1]


max_val = 0
for r, l in zip(L,R):
    if r==None:
        val = l
    elif l==None:
        val = r
    else:
        val = gcd(r, l)
        
    if val > max_val:
        max_val = val
print(max_val)