CodeEff/ECCO huggingface dataset:
# Original solution
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 27 20:57:32 2019

@author: Yamazaki Kenichi
"""

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

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

T = [[1,1,1] for i in range(N)]
T[0][0],T[0][1],T[0][2] = A[0], 0, 0
for i in range(1,N):
    T[i][0] = eg(T[i-1][0],A[i])
    T[i][1] = T[i-1][0]
    T[i][2] = max(eg(T[i-1][2],A[i]),eg(T[i-1][1],A[i]))
print((max(T[N-1])))



# Optimized solution
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 28 15:46:33 2019

@author: Yamazaki Kenichi
"""

N = int(eval(input()))
A = list(map(int,input().split()))
 
def eg(x,y):
    if y == 0:
        return x
    x, y = y, x%y
    return eg(x,y)

L, R = [0 for i in range(N)],[0 for i in range(N)]
L[0], R[N-1] = A[0], A[N-1]
for i in range(1,N):
    L[i] = eg(L[i-1], A[i])
    R[N-1-i] = eg(R[N-i], A[N-1-i])
ans = [0 for i in range(N)]
for i in range(N):
    if i == 0:
        ans[i] = R[i+1]
    elif i == N-1:
        ans[i] = L[i-1]
    else:
        ans[i] = eg(L[i-1],R[i+1])

print((max(ans)))
# Original solution
n = int(eval(input()))
a = []
for x in input().split():
    a.append(int(x))

ans = []

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

def gcd_list(numbers):
    element = gcd(numbers[0], numbers[1])
    if len(numbers)==2:
        return element
    else:
        for i in range(2, len(numbers)):
            element=gcd(element, numbers[i])
        return element

if n == 2:
    print((max(a)))
else:
    for i in range(n):
        c = a.copy()
        c.remove(a[i])
        ans.append(gcd_list(c))

    print((max(ans)))


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

N=int(eval(input()))
A=[int(i) for i in 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])
Z=[gcd(X[i],Y[i]) for i in range(N)]
print((max(Z)))
# Original solution
def gcd(a,b):
    if b == 0:
        return 0
    elif a%b == 0:
        return b
    else:
        return gcd(b,a%b)

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

GCDs = []

for n in range(N):
    B = A + []
    trash = B.pop(n)
    GCD = B[0]
    for b in B:
        GCD = gcd(GCD, b)
    GCDs.append(GCD)

print((max(GCDs)))

# Optimized solution
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()))

L = [0]
R = [0]
for n in range(N-1):
    L.append(gcd(L[-1],A[n]))
    R.append(gcd(R[-1],A[N-n-1]))
    
GCDs = []
for n in range(N):
    GCDs.append(gcd(L[n], R[N-n-1]))
    
print((max(GCDs)))
# Original solution
from functools import reduce
def gcd(a, b):
  l = max(a, b)
  s = min(a, b)
  if s == 0:
    return l
  else:
    return gcd(s, l%s)

n = int(eval(input()))
As = list(map(int, input().split(" ")))
largest = 0
for i in range(n):
  largest = max(largest, gcd(reduce(gcd, As[:i], 0), reduce(gcd, As[i+1:], 0)))
  
print(largest)



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

n = int(eval(input()))
A = [0] + list(map(int, input().split())) + [0]
largest = 0
L = [0 for _ in range(n+2)]
R = [0 for _ in range(n+2)]
for i in range(1, n+2):
  L[i] = gcd(A[i], L[i-1])
  R[n-i+1] = gcd(R[n-i+2], A[n-i+1])

print((max(gcd(L[i-1],R[i+1]) for i in range(1, n+1))))
# Original solution
import sys
sys.setrecursionlimit(10 ** 6)


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


def xgcd(a):
    size = len(a)
    if size == 1:
        return a[0]
    if size == 2:
        return gcd(a[0], a[1])

    la = a[:size // 2]
    ra = a[size // 2:]

    return gcd(xgcd(la), xgcd(ra))


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


ans = 0
for i in range(n):
    tmp = a[i]
    a[i] = a[i - 1]
    ans = max(ans, xgcd(a))
    a[i] = tmp

print(ans)

# Optimized solution
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()))
b = [0] * (n + 1)
c = [0] * (n + 1)

for i in range(n):
    b[i + 1] = gcd(b[i], a[i])
    c[i + 1] = gcd(c[i], a[-i - 1])

ans = 0
for i in range(n):
    ans = max(ans, gcd(b[i], c[n - i - 1]))

print(ans)
# Original solution
from functools import reduce


def gcdd(x, y):
    x, y = max(x, y), min(x, y)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

def gcd(numbers):
    return reduce(gcdd, numbers)

n = int(eval(input()))
a = [int(i) for i in input().split()]
b = []
for i in range(n):
    d = a[:i] + a[i+1:]
    b.append(gcd(d))
print((max(b)))

# Optimized solution
def gcd(x, y):
    if x * y == 0:
        return (x+y)
    x, y = max(x, y), min(x, y)
    while y > 0:
        r = x % y
        x, y = y, r
    return x

n = int(eval(input()))
a = [int(i) for i in input().split()]
l_list = [0]
r_list = [0]
for i in range(n):
    l = gcd(l_list[i], a[i])
    l_list.append(l)
    r = gcd(r_list[-1], a[-i-1])
    r_list.append(r)
r_list = list(reversed(r_list))
r_list = r_list[1:]
l_list = l_list[:n]
c_list = []
for i in range(n):
    c_list.append(gcd(l_list[i], r_list[i]))
print((max(c_list)))
# Original solution
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 __name__ == '__main__':
    n = int(eval(input()))
    a = list(map(int, input().split()))

    numdct = {}
    for i in range(2):
        for div in make_divisors(a[i]):
            if(not div in numdct):
                numdct[div] = 0
            numdct[div] += 1

    for i in range(2, n):
        for num in list(numdct.keys()):
            if(numdct[num] > 0):
                if(a[i] % num != 0):
                    numdct[num] -= 1
    
    numlist = sorted(list(numdct.items()), key=lambda x: -x[1])

    maxnum = 0
    for item in numlist:
        if(item[1] > 0):
            if(maxnum <= item[0]):
                maxnum = item[0]
        else:
            break

    print(maxnum)


# Optimized solution

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 __name__ == '__main__':
    n = int(eval(input()))
    a = list(map(int, input().split()))

    numdct = {}
    for i in range(2):
        for div in make_divisors(a[i]):
            if(not div in numdct):
                numdct[div] = 0
            numdct[div] += 1

    dellist = []
    for i in range(2, n):
        for num in list(numdct.keys()):
            if(a[i] % num != 0):
                numdct[num] -= 1
                if(numdct[num] == 0):
                    dellist.append(num)
        for d in dellist:
            del numdct[d]
        dellist.clear()
    
    numlist = sorted(list(numdct.items()), key=lambda x: -x[1])

    maxnum = 0
    for item in numlist:
        if(item[1] > 0):
            if(maxnum <= item[0]):
                maxnum = item[0]
        else:
            break

    print(maxnum)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
ans1 = a[1]
for i in range(1,n):
  big,sml = a[i],ans1
  while sml != 0:
    big,sml = sml,big%sml
  ans1 = big
ans2 = a[-2]
for i in range(n-1):
  big,sml = a[i],ans2
  while sml != 0:
    big,sml = sml,big%sml
  ans2 = big
l1 = [-1]
now = a[0]
for i in range(1,n):
  big,sml = now,a[i]
  while sml != 0:
    big,sml = sml,big%sml
  l1.append(now // big)
  now = big
l2 = [-1]
now = a[-1]
for i in range(n-2,-1,-1):
  big,sml = now,a[i]
  while sml != 0:
    big,sml = sml,big%sml
  l2.append(now // big)
  now = big
l2.reverse()
l3 = [-1]
for i in range(1,n-1):
  big,sml = l1[i],l2[i]
  while sml != 0:
    big,sml = sml,big%sml
  l3.append(big)
l3.append(-1)
now = a[0]
for i in range(n):
  big,sml = now,a[i]
  while sml != 0:
    big,sml = sml,big%sml
  now = big
ans3 = now * max(l3)
#print(now)
#print(l1)
#print(l2)
#print(l3)
#print(ans1,ans2,ans3)
print((max(ans1,ans2,ans3)))

# Optimized solution
#14:10
n = int(eval(input()))
a = list(map(int,input().split()))
b = []
for i in range(n):
  if i == 0:
    b.append(a[i])
  else:
    big = b[-1]
    sml = a[i]
    while sml != 0:
      big,sml = sml,big%sml
    b.append(big)
c = []
for j in range(n)[::-1]:
  if j == n-1:
    c.append(a[j])
  else:
    big = c[-1]
    sml = a[j]
    while sml != 0:
      big,sml = sml,big%sml
    c.append(big)
c.reverse()
d = []
for i in range(n):
  if i == 0:
    d.append(c[1])
  elif i == n-1:
    d.append(b[n-2])
  else:
    big = b[i-1]
    sml = c[i+1]
    while sml != 0:
      big,sml = sml,big%sml
    d.append(big)
#print(b)
#print(c)
#print(d)
print((max(d)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
def gcd(a,b):
    if a==b:
      return a
    else:
      a,b=max(a,b),min(a,b)
      if a%b==0:
        return b
      else:
        return gcd(b,a%b)
def gcd_for_list(L):
    if len(L)==1:
      return L[0]
    for i in range(len(L)):
      if i==0:
        tmp=gcd(L[i],L[i+1])
      elif i==1:
        pass
      else:
        tmp=gcd(tmp,L[i])
    return tmp
ans=0
for i in range(0,n):
  if i==0:
    ans=max(ans,gcd_for_list(a[i+1:]))
  elif i==n-1:
    ans=max(ans,gcd_for_list(a[0:i]))
  else:
    l_r=a[0:i]
    l_l=a[i+1:]
    ans=max(ans,gcd(gcd_for_list(l_r),gcd_for_list(l_l)))
print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
def gcd(a,b):
    if a==b:
      return a
    else:
      a,b=max(a,b),min(a,b)
      if a%b==0:
        return b
      else:
        return gcd(b,a%b)
R=[]
L=[]
for i in range(n):
  if i==0:
    L.append(a[i])
    R.append(a[-i-1])
  else:
    vl,vr=gcd(a[i],L[-1]),gcd(a[-i-1],R[-1])
    L.append(vl)
    R.append(vr)
ans=0
for i in range(n):
  if i==0:
    ans=max(ans,R[-i-2])
  elif i==n-1:
    ans=max(ans,L[i-1])
  else:
    ans=max(ans,gcd(L[i-1],R[-i-2]))
print(ans)
# Original solution
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


def list_gcd(a):
    a_gcd = a[0]
    for i in range(n-1):
        a_gcd = gcd(a_gcd, a[i+1])
    return a_gcd


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

for i in range((n+1)//2):
    b = a[:]
    b[i] = b[i-1]
    ans = max(ans, list_gcd(b))

print(ans)

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


n = int(eval(input()))
a = list(map(int, input().split()))
a = [0]+a[:]+[0]

l = [0]*len(a)
r = [0]*len(a)

for i in range(len(a)-1):
    m = len(a)-1
    l[i+1] = gcd(l[i], a[i+1])
    r[m-i-1] = gcd(r[m-i], a[m-i-1])

ans = [0]*n

for i in range(n):
    ans[i] = gcd(l[i], r[i+2])

print((max(ans)))
# Original solution

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return int(a)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)
  return ans
    
n = int(eval(input()))

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

maxgcd = 0
for i in range(n):
  nums = [a[j] for j in range(n) if j!=i]
  #print(nums)
  tmp = gcd3(nums)
  if maxgcd<tmp:
    maxgcd=tmp
    
print(maxgcd)




# Optimized solution

import sys

def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return int(a)
    
n = int(eval(input()))
a = list(map(int, input().split()))


if n==2:
  print((max(a)))
  sys.exit(0)
elif n==3:
  lis = [gcd(a[0], a[1]), gcd(a[1], a[2]), gcd(a[2], a[0])]
  print((max(lis)))
  sys.exit(0)


tmp_unused = gcd(a[0], a[1])
tmp_used = max(a[0], a[1])
#print("used=", tmp_used, "unused=", tmp_unused)

for i in range(2,n):
  #print(a[i])
  tmp_used = max(tmp_unused, gcd(tmp_used, a[i]))
  tmp_unused = gcd(tmp_unused, a[i])
  
  #print("used=", tmp_used, "unused=", tmp_unused)
print(tmp_used)
# Original solution
n = int(eval(input()))
l = list(map(int, input().split()))

def gcd(x,y):
  while y:
    x, y = y, x%y
  return x

ans = 0
for i in range(n):
  g = l[0] if i > 0 else l[1]
  for j in range(1,n):
    if j != i:
      g = gcd(g, l[j])
  ans = max(ans, g)

print(ans)

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

def gcd(x,y):
  while y:
    x, y = y, x%y
  return x

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

print((max(ll[n-2], lr[1], *[gcd(l,r) for l,r in zip(ll[:n-2], lr[2:])])))
# Original solution
import sys
input = sys.stdin.readline

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

def gcd(x,y):
  while y:
    x, y = y, x%y
  return x

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

print((max(ll[n-2], lr[1], *[gcd(l,r) for l,r in zip(ll[:n-2], lr[2:])])))

# Optimized solution
n=int(eval(input()))
a=[*list(map(int,input().split()))]
from math import *
l=a.copy()
r=a.copy()
for i in range(n-1):
  l[i+1]=gcd(l[i],l[i+1])
  r[-i-2]=gcd(r[-i-1],r[-i-2])
a=max(l[-2],r[1])
for i in range(1,n-1):
  a=max(a,gcd(l[i-1],r[i+1]))
print(a)
# Original solution
n=int(eval(input()))
a=[*list(map(int,input().split()))]
from math import *
l=a.copy()
r=a.copy()
for i in range(n-1):
  l[i+1]=gcd(l[i],l[i+1])
  r[-i-2]=gcd(r[-i-1],r[-i-2])
a=max(l[-2],r[1])
for i in range(1,n-1):
  a=max(a,gcd(l[i-1],r[i+1]))
print(a)

# Optimized solution
n=int(eval(input()))
a=[*list(map(int,input().split()))]
from math import *
l,r=[0]*n,[0]*n
for i in range(1,n):
  l[i]=gcd(l[i-1],a[i-1])
  r[~i]=gcd(r[-i],a[-i])
m=0
for i in range(n):
  m=max(m,gcd(l[i],r[i]))
print(m)
# Original solution
n=int(eval(input()))
A=list(map(int,input().split()))
L=[0]*(n+1)
R=[0]*(n+1)
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
for i in range(n):
    L[i+1]=gcd(L[i],A[i])
for i in range(n,0,-1):
    R[i-1]=gcd(R[i],A[i-1])
ans=[]
for k in range(n):
    ans.append(gcd(L[k],R[k+1]))
print((max(ans)))


# Optimized solution
n=int(eval(input()))
A=list(map(int,input().split()))
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
L=[0]
R=[0]
for i in range(n):
    L.append(gcd(L[i],A[i]))
    R.append(gcd(R[i],A[-(i+1)]))
R=R[::-1]

ans=[]
for i in range(n):
    ans.append(gcd(L[i],R[i+1]))
print((max(ans)))
# Original solution
import functools
n = int(eval(input()))
a_list = list(map(int,input().split()))

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            x,y = y,x%y
        return y

res = []
tmp = []
for i in range(n):
    if a_list[i] in tmp:
        continue
    if a_list[:i]==[]:
        res.append(functools.reduce(gcd, a_list[i+1:]))
    elif a_list[i+1:]==[]:
        res.append(functools.reduce(gcd, a_list[:i]))
    else:
        l_gcd = functools.reduce(gcd, a_list[:i])
        r_gcd = functools.reduce(gcd, a_list[i+1:])
        res.append(gcd(l_gcd,r_gcd))
    tmp.append(a_list[i])
print((max(res)))

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

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if y==0:
        return x
    else:
        while x%y!=0:
            x,y = y,x%y
        return y

res = []
l_gcd = [0]*(n+2)
r_gcd = [0]*(n+2)
for i in range(n+1):
    if i ==0:
        l_gcd[i] = 0
        r_gcd[n-i+1] = 0
        continue
    l_gcd[i] = gcd(l_gcd[i-1], a_list[i-1])
    r_gcd[n-i] = gcd(r_gcd[n-i+1], a_list[n-i])

for i in range(n+1):
    res.append(gcd(l_gcd[i],r_gcd[i+1]))

print((max(res)))
# Original solution
n = int(eval(input()))
alist = [int(i) for i in input().split()]
alist.sort()

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


def get_custum(xlist):
    prev = None
    gcm_list = []
    for a in xlist:
        if prev is None:
            gcm_list.append(a)
            prev = a
            continue
        ret = calc_gcm(a, prev)
        gcm_list.append(ret)
        prev = ret

    for boundary, gcm in enumerate(gcm_list):
        if gcm == gcm_list[-1]:
            break

    gcm_1 = None
    for i, a in enumerate(xlist):
        if i == boundary - 1:
            continue
        if gcm_1 is None:
            gcm_1 = a
            continue
        gcm_1 = calc_gcm(a, gcm_1)

    gcm_2 = None
    for i, a in enumerate(xlist):
        if i == boundary:
            continue
        if gcm_2 is None:
            gcm_2 = a
            continue
        gcm_2 = calc_gcm(a, gcm_2)

    return max(gcm_1, gcm_2)

ret1 = get_custum(alist)
alist.reverse()
ret2 = get_custum(alist)

print((max(ret1, ret2)))


# Optimized solution
n = int(eval(input()))
alist = [int(i) for i in input().split()]

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


def listup_gcm(xlist):
    list_gcm = []
    prev = None
    for a in xlist:
        if prev is None:
            list_gcm.append(a)
            prev = a
            continue
        gcm = calc_gcm(prev, a)
        list_gcm.append(gcm)
        prev = gcm
    return list_gcm


left_gcm = listup_gcm(alist)
alist.reverse()
right_gcm = listup_gcm(alist)
right_gcm.reverse()


maxgcm = 0
for i in range(n):
    if i == 0:
        maxgcm = max(maxgcm, right_gcm[1])
    elif i == n - 1:
        maxgcm = max(maxgcm, left_gcm[n-2])
    else:
        maxgcm = max(maxgcm, calc_gcm(left_gcm[i-1], right_gcm[i+1]))

print(maxgcm)
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

class SegmentTree:
    def __init__(self, N, func, I):
        self.func = func
        self.I = I
        self.sz = 2**(N-1).bit_length()
        self.seg = [I] * (self.sz * 2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = list(map(int,read().split()))
    seg = SegmentTree(N , gcd , 0)
    for i,n in enumerate(L):
        seg.assign(i , n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

class SegmentTree:
    def __init__(self, N, func, I):
        self.func = func
        self.I = I
        self.sz = 2**(N-1).bit_length()
        self.seg = [I] * (self.sz * 2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in reversed(list(range(1,self.sz))):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = list(map(int,read().split()))
    seg = SegmentTree(N , gcd , 0)
    for i,n in enumerate(L):
        seg.assign(i , n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

class SegmentTree:
    def __init__(self, N, func, I):
        self.func = func
        self.I = I
        self.N = N
        self.sz = 2**(N-1).bit_length()
        self.seg = [I] * (self.sz * 2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in reversed(list(range(1,self.sz))):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = list(map(int,readline().split()))
    seg = SegmentTree(N , gcd , 0)
    for i,n in enumerate(L):
        seg.assign(i , n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


# Optimized solution
import sys
readline = sys.stdin.buffer.readline


class SegmentTree:
    def __init__(self, N, func, I):
        self.N = N
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(list(range(1, self.sz))):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        if b == self.N:
            b = self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)


def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = list(map(int, readline().split()))
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)


main()