CodeEff/ECCO huggingface dataset:
# 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)


def gcda(a):
    ret = a[0]
    for i in range(1, len(a)):
        ret = gcd(ret, a[i])
    return ret


ans = 1
for i in range(N):
    a = A[:i] + A[i+1:]
    ans = max(ans, gcda(a))

print(ans)

# Optimized 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
    return gcd(b, a % b)


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

for i in range(N-1, -1, -1):
    R[i] = gcd(R[i+1], A[i])

ans = 1
for i in range(N):
    ans = max(ans, gcd(L[i], R[i+1]))

print(ans)
# Original solution
import functools

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

l_gcd = []

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

for i,j in enumerate(A):
    B = j
    A.pop(i)
    l_gcd.extend([functools.reduce(gcd,A)])
    A.insert(i,B)

print((max(l_gcd)))


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

w_min = A[1]

for i in range(w_min,0,-1):
    count = 0
    for j in A:
        if j%i != 0:
            count = count + 1
            if count > 1:
                break
    if count < 2:
        print(i)
        break
# Original solution
from math import gcd
n = int(eval(input()))
A = tuple(map(int, input().split()))

from collections import deque
q = deque([])
q.append([0, A[0], False])
q.append([1, A[1], True])
# 深さ優先探索
# idx, これまでのGCD, 抜いたか抜いてないか
ans = 0
while q:
    idx, g, jogai = q.pop()
    if g <= ans:
        continue
    if idx == n-1:
        ans = max(ans, g)
        continue

    q.append([idx+1, gcd(g, A[idx+1]), jogai])
    if not jogai:
        q.append([idx+1, g, True])
print(ans)

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

# 以降のGCD
left_gcds = [A[0]]
for a in A[1:]:
    left_gcds.append(gcd(left_gcds[-1], a))

right_gcds = [A[-1]]
for a in A[:n-1][::-1]:
    right_gcds.append(gcd(right_gcds[-1], a))
right_gcds.reverse()

ans = 0
for i in range(n):
    if i == 0:
        tmp = right_gcds[i+1]
    elif i == n-1:
        tmp =left_gcds[i-1]
    else:
        tmp = gcd(left_gcds[i-1], right_gcds[i+1])
    ans = max(ans, tmp)
print(ans)
# Original solution
def gcd(a,b) :
    r = a % b
    if r == 0 :
        return b
    else :
        return gcd(b,r)

N = int(eval(input()))

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

L = [0] * N
R = [0] * N

for i in range(N) :  # iより左(右)
    if i == 0 :
        L[i] = A[i]
        R[-i-1] = A[-i-1]
    else :
        L[i] = gcd(L[i-1], A[i-1])
        R[-i-1] = gcd(R[-i],A[-i])

ans = 1

for i in range(N) :
    if i == 0 :
        new = R[i]
    elif i == N-1 :
        new = L[i]
    else :
        new = gcd(L[i],R[i])
    if ans < new :
        ans = new

print(ans)

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

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

leftGcd = [-1] * (N + 1)
leftGcd[0] = A[0]

for i, a in enumerate(A, start=1):
    leftGcd[i] = gcd(leftGcd[i - 1], a)

rightGcd = [-1] * (N + 1)
rightGcd[-1] = A[-1]

for i, a in enumerate(reversed(A), start=1):
    rightGcd[-(i + 1)] = gcd(rightGcd[-i], a)

ans = max(rightGcd[1], leftGcd[-2])
for mid in range(1, N):
    ans = max(ans, gcd(leftGcd[mid], rightGcd[mid + 1]))

print(ans)
# Original solution
import sys
sys.setrecursionlimit(1000000)
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
n = int(eval(input()))
A = list(map(int, input().split()))
def left(i):
    if i < 1:
        return 0
    return gcd(left(i-1), A[i-1])
def right(i):
    if i+1 > n-1:
        return 0
    return gcd(right(i+1), A[i+1])
ans = 0
for i in range(n):
    ans = max(ans, gcd(left(i), right(i)))
print(ans)

# Optimized solution
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
n = int(eval(input()))
A = list(map(int, input().split()))
L = [0]*n
R = [0]*n
for i in range(n-1):
    R [i+1] = gcd(R[i], A[i])
    L[i+1] = gcd(L[i], A[-i-1])
print((max(gcd(R[i], L[-i-1]) for i in range(n))))
# Original solution
def gcd_(a,b):
    if a<b:    a,b=b,a
    if b==0:    return a
    return gcd_(b,a%b)
  
def gcd(l):
    ans=l[0]
    for i in l:
        ans=gcd_(ans,i)
    return ans
  
N=int(eval(input()))
a=list(map(int,input().split()))
ans=0
for i in range(N):
    ans=max(ans,gcd(a[:i]+a[i+1:]))
print(ans)

# Optimized solution
def gcd_(a,b):
    if a<b:    a,b=b,a
    if b==0:    return a
    return gcd_(b,a%b)
  
def gcd(l):
    ans=l[0]
    for i in l:
        ans=gcd_(ans,i)
    return ans


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

gcd_list=[A[0]]
rev_gcd_list=[A[-1]]

for i in range(1,N):
    gcd_list.append(gcd([gcd_list[-1],A[i]]))
    rev_gcd_list.append(gcd([rev_gcd_list[-1],A[-i-1]]))
rev_gcd_list=rev_gcd_list[::-1]

ans=max(gcd_list[N-2],rev_gcd_list[1])
for i in range(1,N-1):
    ans=max(ans,gcd([gcd_list[i-1],rev_gcd_list[i+1]]))
print(ans)
# Original solution
n = int(eval(input()))
ls = list(map(int, input().split()))
p = 50
ans = 0
if p>n:p=n

def gcd(a,b):
    if a < b:
        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
    
for i in range(p):
    s = cul(i,ls[: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()))
if p>N: p=N
a=list(map(int,input().split()))

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

print(ans)
# Original solution
def gcd(s):
    list=[]
    for j in range(len(s)):
        a=0
        b=0
        temp=10000000000000000000
        v=[]
        if len(s)>2:
            for i in range(len(s)):
                if i!=j:
                    x=s[i]
                    v.append(x)
            for i in range(len(v)):
                if i==0:
                    a=v[i]
                    b=v[i+1]
                else:
                    b=v[i]
                if a<b:
                    temp=a
                    a=b
                    b=temp
                while b!=0:
                    temp=a%b
                    a=b
                    b=temp
            list.append(a)
        else:
            list.append(max(s))
    return(max(list))


n=int(eval(input()))

v=[]
line=input().split()

for i in range(n):
    v.append(int(line[i]))

print((gcd(v)))

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

n=int(eval(input()))

v=[]
line=input().split()

for i in range(n):
    v.append(int(line[i]))

gcd_l=[]
gcd_r=[]

for i in range(n-1):
    if i==0:
        gcd_l.append(v[i])
    else:
        gcd_l.append(gcd(gcd_l[i-1],v[i]))

for i in range(n-1):
    if i==0:
        gcd_r.append(v[n-1])
    else:
        gcd_r.append(gcd(gcd_r[i-1],v[n-i-1]))

gcd_list=[]

for i in range(n):
    if i==0:
        gcd_list.append(gcd_r[n-2])
    elif i==n-1:
        gcd_list.append(gcd_l[n-2])
    else:
#        print(gcd(gcd_l[i-1],gcd_r[n-i-2]))
        gcd_list.append(gcd(gcd_l[i-1],gcd_r[n-i-2]))

#print(gcd_list)

print((max(gcd_list)))
# Original solution
from functools import reduce

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


def gcd(x, y):
    if x < y:
        x, y = y, x
    while y != 0:
        tmp = x % y
        x = y
        y = tmp
    return x


ans = 1
if N == 2:
    print((max(a)))
    exit()


for i in range(N):
    if i == 0:
        n = reduce(gcd, a[1:])
    elif i == N-1:
        n = reduce(gcd, a[:i])
    else:
        n = reduce(gcd, a[:i]+a[i+1:])
    ans = max(ans, n)
print(ans)

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


def gcd(x, y):
    if x < y:
        x, y = y, x
    while y != 0:
        tmp = x % y
        x = y
        y = tmp
    return x


ans = 1
if N == 2:
    print((max(a)))
    exit()

l = [1] * N
l[0] = a[0]
r = [1] * N
r[N-1] = a[N-1]
for i in range(1, N):
    l[i] = gcd(l[i-1], a[i])
    r[N-1-i] = gcd(r[N-i], a[N-1-i])
    
for i in range(N):
    if i == 0:
        n = r[1]
    elif i == N-1:
        n = l[N-2]
    else:
        n = gcd(l[i-1], r[i+1])
    ans = max(ans, n)
print(ans)
# Original solution
N = int(eval(input()))
A = [int(i) for i in input().split()]


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


L = [A[0]]
R = [A[-1]]
for i in range(1, N):
    L.append(gcd(L[i-1], A[i]))
    R.insert(0, gcd(R[0], A[N-1-i]))


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

print(ans)


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


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


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

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

print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

def gcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    if y == 0:
        return x
    return gcd(y, x % y)

param = [[0, 0, 0]]
addr = 0
while True:
    if len(param) <= 0:
        break
    addr, Li, Lv = param.pop()
    if addr == 0:
        if Li == N-1:
            Rv = 0
            M, isCall = Lv, False
            continue            
        param += [[1, Li, Lv], [0, Li+1, gcd(Lv, A[Li])]]
        isCall = True
        continue 
    elif addr == 1:
        Rv = gcd(A[Li+1], Rv)
        M, isCall = max(M, gcd(Lv, Rv)), False
        continue

print(M)


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

def gcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    return gcd(y, x % y) if y!=0 else x

def F(init, add):
    w = [0]
    for i in range(init, init + add * N, add):
        w += [gcd(w[-1], A[i])]
    return w[:-1]

print((max(list(map(lambda x,y:gcd(x,y), F(0, 1), F(N-1, -1)[::-1])))))
# Original solution
from math import sqrt
from sys import exit
N=int(eval(input()))
A=list(map(int,input().split()))

if len(A)==2:
    print((max(A)))
    exit()

def gcd(a,b):
    if a<b: a,b=b,a
    if a%b==0: return b
    return gcd(b,a%b)
    
g=gcd(A[0],A[-1])

p=[]

for i in range(1,int(sqrt(g)+1)):
    if g%i==0:
        if i*i==g: p.append(i)
        else: p+=[i,g//i]
        
def ok(n):
    f=False
    for a in A[1:-1]:
        if a%n:
            if f: return False
            f=True
    return True
    
def GCD(L):
    if len(L)==1: return L[0]
    ans=gcd(L[0],L[1])
    if len(L)>2:
        for l in L[2:]:
            ans=gcd(ans,l)
    return ans

p.sort(reverse=True)
for num in p:
    if ok(num):
        ans=num
        break
p1=GCD(A[1:-1])
print((max([ans,gcd(p1,A[0]),gcd(p1,A[-1])])))


# Optimized solution
from math import sqrt
from sys import exit
N=int(eval(input()))
A=list(map(int,input().split()))

if len(A)==2:
    print((max(A)))
    exit()

def gcd(a,b):
    if a<b: a,b=b,a
    if a%b==0: return b
    return gcd(b,a%b)
    
g=A[0]
L=[g]
for a in A[1:-1]:
    g=gcd(g,a)
    L.append(g)
    
g=A[-1]
R=[g]
for a in A[1:-1][::-1]:
    g=gcd(g,a)
    R.append(g)

ans=max(L[-1],R[-1])
for l,r in zip(L[:-1],R[:-1][::-1]):
    ans=max(ans,gcd(l,r))
print(ans)
# Original solution
#!/usr/bin/env python3
import sys
from math import gcd
from functools import reduce

def f(A):
    ret = [A[0]]
    for a in A:
        ret.append(gcd(ret[-1], a))
    ret[0] = reduce(gcd, A[1:])
    return ret

def solve(N: int, A: "List[int]"):    
    return  max(gcd(g0, g1) for g0, g1 in zip(f(A), f(A[::-1])[-2::-1]))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print((solve(N, A)))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
from math import gcd

def f(A):
    ret = [0]
    for a in A:
        ret.append(gcd(ret[-1], a))
    return ret

def solve(N: int, A: "List[int]"):    
    return  max(gcd(g0, g1) for g0, g1 in zip(f(A), f(A[::-1])[-2::-1]))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print((solve(N, A)))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()
# Original solution
# -*- coding: utf-8 -*-
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

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


g_max = 1
for i in range(n):
    d = a_l.pop(0)

    if n-1==1:
        g = a_l[0]
    else:
        g = gcd(a_l[0], a_l[1])
        if n-1!=2:
            for j in range(2,n-1):
                g=gcd(g,a_l[j])
    # print(g)
    g_max = max(g, g_max)
    # print(d)
    a_l.append(d)

print(g_max)

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

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

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

# 累積GCD
left = [0]*(n+1)
right = [0]*(n+1)
for i in range(n):
    left[i+1] = gcd(left[i], a[i])
for i in reversed(list(range(n))):
    right[i] = gcd(right[i+1], a[i])

# print(left)
# print(right)

# 集計
ans = 0
for i in range(n):
    l = left[i]
    r = right[i+1]
    ans = max(ans, gcd(l, r))

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

    return gcd(b % a, a)


N = int(eval(input()))
A = [int(v) for v in input().split()]
max_gcd = -1

for i in range(N):
    tmp = None
    for j in range(N):
        if j == i: continue
        if tmp is None:
            tmp = A[j]
            continue

        # print(tmp, A[j], gcd(tmp, A[j]))
        tmp = gcd(tmp, A[j])
    max_gcd = max(tmp, max_gcd)
if max_gcd < 0:
    print((A[0]))
else:
    print(max_gcd)


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


def gcd(a, b):
    if a > b:
        a, b = b, a

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


L = [0 for _ in range(N + 2)]
R = [0 for _ in range(N + 2)]

for i, a in enumerate(A):
    L[i + 1] = gcd(A[i], L[i])
    R[N-i] = gcd(A[N-i-1], R[N-i+1])

# print(L)
# print(R)

res = -2
for i in range(1, N+1):
    res = max(res, gcd(L[i-1], R[i+1]))
print(res)
# Original solution
import math

N=int(eval(input()))
A=list(map(int,input().split()))
L=[0]*(N+1)
for i in range(N):
  L[i+1]=math.gcd(L[i],A[i])
R=[0]*(N+1)
for i in range(N-1,-1,-1):
  R[i]=math.gcd(R[i+1],A[i])
M=[]
for i in range(N):
  M.append(math.gcd(L[i],R[i+1]))
print((max(M)))


# Optimized solution
from math import *

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

left=[0]*(N+1)
for i in range(N):
  left[i+1]=gcd(left[i],A[i])

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

ans=0
for i in range(N):
  ans=max(ans,gcd(left[i],right[i+1]))

print(ans)
# Original solution
import math

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義
    
def list_gcd(x):
    if len(x) == 1:
        return x[0]
    next_list = []
    for i in range(int(len(x)/2)):
        next_list.append(gcd(x[2*i],x[2*i+1]))
    if len(x)%2 == 1:
        next_list.append(x[-1])
    
    return list_gcd(next_list)

out = 0
for i in range(len(A)):
    l = A[:i] + A[i+1:]
    this_gcd = list_gcd(l)
    if this_gcd > out:
        out = this_gcd
        
print(out)

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義
    
list_gcd = [(gcd(A[0],A[1]),False),(A[0],True),(A[1],True)]
#print(list_gcd)

for i in range(2,len(A)):
    next_gcd = []
    for j in list_gcd:
        if j[1]:
            this_gcd = (gcd(j[0],A[i]),True)
            if not(this_gcd in next_gcd):
                next_gcd.append(this_gcd)
        else:
            this_gcd = (gcd(j[0],A[i]),False)
            if not(this_gcd in next_gcd):
                next_gcd.append(this_gcd)
                
            this_gcd = (j[0],True)
            if not(this_gcd in next_gcd):
                next_gcd.append(this_gcd)
    list_gcd = next_gcd
    #print(list_gcd)
         
out = 1
for i in list_gcd:
    if i[0] > out:
        out = i[0]
        
print(out)
# Original solution
import copy
n = int(eval(input()))
a = list(map(int,input().split()))
ans = 1
if len(a) == 2:
  print((max(a)))
else:
  for i in range(n):
    b = copy.deepcopy(a)
    b.pop(i)
    b.sort
    b0 = b[0]
    for j in range(1,n-1):
      b1 = b[j]
      r = 0
      while True:
        r = b1 % b0
        if r == 0:
          break
        elif r > b0:
          b1, b0 = r, b0
        else:
          b1, b0 = b0, r
    if b0 > ans:
      ans = b0
  print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
ans = 1
if n == 2:
  print((max(a)))
else:
  a0 = a[0]
  a1 = a[1]
  r = 0
  while True:
    r = a1 % a0
    if r == 0:
      b0 = a0
      break
    elif r > a0:
      a1, a0 = r, a0
    else:
      a1, a0 = a0, r
  a1 = a[1]
  a2 = a[2]
  r = 0
  while True:
    r = a2 % a1
    if r == 0:
      b1 = a1
      break
    elif r > a1:
      a2, a1 = r, a1
    else:
      a2, a1 = a1, r
  a0 = a[0]
  a2 = a[2]
  r = 0
  while True:
    r = a2 % a0
    if r == 0:
      b2 = a0
      break
    elif r > a0:
      a2, a0 = r, a0
    else:
      a2, a0 = a0, r
  max_a = max(b0,b1,b2)
  kouho = []
  for j in range(max_a,1,-1):
    if max_a % j == 0:
      c = list([x % j for x in a])
      c_ng = [i for i in c if i > 0]
    #print("j=",j,"c=",c,"c_ng=",c_ng)
      if len(c_ng) <= 1:
        ans = j
        break
  print(ans)
# Original solution
n=int(eval(input()))
a=[int(x) for x in input().split()]
from collections import defaultdict
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
print((max([x for x in list(d.keys()) if d[x]==n or d[x]==n-1])))

# Optimized solution
n=int(eval(input()))
a=[int(x) for x in input().split()]
anses=set()
for i in [0,1]:
    for j in range(1, int(a[i]**0.5)+1):
        if a[i] % j == 0:
            anses.add(j)
            if j != a[i] // j:
                anses.add(a[i] // j)
anses=sorted(anses,reverse=True)
for ans in anses:
    solvenum=0
    for j in a:
        if j%ans==0:
            solvenum+=1
    if solvenum==n or solvenum==n-1:
        print(ans)
        break
# Original solution
from functools import reduce

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

def gcd(x,y):
	x_ = max(x,y)
	y_ = min(x,y)
	if y_==0:
		return 0
	if x_%y_==0:
		return y_
	return gcd(y_, x_%y_)

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

gcds = [gcd_list(a[:i]+a[i+1:]) for i in range(n)]

print((max(gcds)))


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

def gcd(x_,y_):
	x = max(x_, y_)
	y = min(x_, y_)
	if y==0:
		return x
	if x%y == 0:
		return y
	return gcd(y, x%y)

L = [0]*n
R = [0]*n
L[0] = a[0]
R[-1] = a[-1]

for i in range(1,n):
	L[i] = gcd(L[i-1], a[i])
	j = n-1-i
	R[j] = gcd(R[j+1], a[j])

L = [0]+L
R = R + [0]
M = [0]*n
for i in range(n):
	M[i] = gcd(L[i],R[i+1])
print((max(M)))
# Original solution
#!/usr/bin/env pypy3

import collections
import math


def solve(n, xs):
    divisors = collections.Counter()
    for x in xs:
        for y in range(1, math.floor(math.sqrt(x)) + 1):
            d, m = divmod(x, y)
            if m == 0:
                divisors[y] += 1
                if y != d:
                    divisors[d] += 1
    for i in range(1, max(xs) + 1)[::-1]:
        if divisors[i] >= n - 1:
            return i


def main():
    n = int(eval(input()))
    xs = [int(x) for x in input().split()]
    print((solve(n, xs)))


if __name__ == "__main__":
    main()

# Optimized solution
#!/usr/bin/env python3

import itertools
try:
    from math import gcd
except ImportError:
    from fractions import gcd


class Cumulative(object):

    def __init__(self, seq, op):
        self.cumul_array = [0]
        self.cumul_array.extend(itertools.accumulate(seq, op))


def solve(n, xs):
    left_cumul = Cumulative(xs, gcd)
    right_cumul = Cumulative(reversed(xs), gcd)
    res = 1
    for i in range(n):
        left_gcd = left_cumul.cumul_array[i]
        right_gcd = right_cumul.cumul_array[n - i - 1]
        cand = gcd(left_gcd, right_gcd)
        if cand > res:
            res = cand
    return res


def main():
    n = int(eval(input()))
    xs = [int(x) for x in input().split()]
    res = solve(n, xs)
    print(res)


if __name__ == "__main__":
    main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

def divisor(x):
    ret = []
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            ret.append(i)
            if i*i != x:
                ret.append(x//i)
    return ret

divisor_dict = {}
for i in range(len(A)):
    div = divisor(A[i])
    for j in div:
        if j in divisor_dict:
            divisor_dict[j] += 1
        else:
            divisor_dict[j] = 1

max_val = 0
for key, val in list(divisor_dict.items()):
    if val >= N-1 and key > max_val:
        max_val = key

print(max_val)


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

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

    return b

L = [0] * (N+1)
R = [0] * (N+2)

for i in range(1, N+1):
    ind = N+1-i
    L[i] = gcd(L[i-1], A[i-1])
    R[ind] = gcd(R[ind+1], A[ind])

ret = []
for i in range(1, N+1):
    ret.append(gcd(L[i], R[i+1]))

print((max(ret)))
# Original solution

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

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

kous = list(map(make_divisors, As))
all = []
for v in kous:
    all += v
all = sorted(list(set(all)), reverse=True)

ans = 1
i = 0
for v in all:
    count = 0
    for k in kous:
        if v in k:
            count += 1
    if count >= N-1:
        ans = all[i]
        break
    i+=1
    
print(ans)


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



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

left_gcds = [gcd(As[0], As[0])]
for i in range(1, len(As)):
    left_gcds.append(gcd(left_gcds[i-1], As[i]))

right_gcds = [gcd(As[-1], As[-1])]
for i in range(1, len(As)):
    right_gcds.append(gcd(right_gcds[i-1], As[-(i+1)]))
right_gcds.reverse()

gcds = []
for i in range(N):
    if i == 0:
        gcds.append(right_gcds[1])
    elif i == N-1:
        gcds.append(left_gcds[-2])
    else:
        gcds.append(gcd(left_gcds[i-1], right_gcds[i+1]))
print((max(gcds)))