CodeEff/ECCO huggingface dataset:
# Original 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()))
ans = a[0]
for i in range(n):
    ans = gcd(i,ans)
for i in range(n):
    if i==0:
        t = a[1]
    else:
        t = a[0]
    for j in range(n):
        if j==i:
            continue
        t = gcd(a[j],t)
        if t<=ans:
            break
    ans = max(t,ans)
print(ans)


# 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()))
r = []
l = []
t = a[0]
for i in a:
    t = gcd(t, i)
    l.append(t)
t = a[-1]
for i in a[::-1]:
    t = gcd(t, i)
    r.append(t)
r = r[::-1]
ans = 0
for i in range(n):
    if i == 0:
        ans = max(ans, r[1])
        continue
    if i == n - 1:
        ans = max(ans, l[-2])
        continue
    ans = max(ans, gcd(l[i-1], r[i+1]))

print(ans)
# Original solution
import sys

def gcd(x, y, *val):
    val = [x, y] + list(val)
    count = len(val)

    if count == 2:
        mod = val[0] % val[1]
        if mod == 0:
            return val[1]
        elif mod == 1:
            return 1
        else:
            return gcd(val[1], mod)
    else:
        if count % 2 == 1:
            val.append(val[-1])

        return gcd(*[gcd(val[i], val[i + 1]) for i in range(0, count, 2)])
        

def main():
    sinputl = sys.stdin.readline

    num = int(sinputl().strip())
    input = [int(x) for x in sinputl().split()]

    gcd_max = 1
    input_mem = []

    if num == 2:
        print((max(input)))
        return

    for i in range(num):
        mem = input.pop(num - 1 - i)
        gcd_max = max(gcd_max, gcd(*(input + input_mem)))
        input_mem.append(mem)

    print(gcd_max)



if __name__ == "__main__":
    main()

# Optimized solution
import sys

def gcd(x, y, *val):
    val = sorted([x, y], reverse=True) + list(val)
    count = len(val)

    if count == 2:
        if val[1] == 0:
            return val[0]

        mod = val[0] % val[1]
        if mod == 0:
            return val[1]
        elif mod == 1:
            return 1
        else:
            return gcd(val[1], mod)
    else:
        if count % 2 == 1:
            val.append(val[-1])

        return gcd(*[gcd(val[i], val[i + 1]) for i in range(0, count, 2)])
        

def main():
    sinputl = sys.stdin.readline

    num = int(sinputl().strip())
    input = [int(x) for x in sinputl().split()]

    gcd_max = 1
    input_mem = []

    if num == 2:
        print((max(input)))
        return

    gcd_left = [0]
    gcd_right = [0]

    for i in range(num - 1):
        gcd_left.append(gcd(input[i], gcd_left[i]))
        gcd_right.append(gcd(input[-1 - i], gcd_right[i]))

    gcd_right.reverse()
    gcd_list = []

    for i in range(num):
        gcd_list.append(gcd(gcd_left[i], gcd_right[i]))

    print((max(gcd_list)))



if __name__ == "__main__":
    main()
# Original solution
def gcd(a, b):
    r = a % b
    return b if 0 == r else gcd(b, r)


def gcd_list(lst):
    a = lst[0]
    for i in lst[1:]:
        a = gcd(a, i)
    return a


n = int(eval(input()))
a = list(map(int, input().split()))
max_value = max(a)
ans = 0
for i in range(n):
    target = [a[j] for j in range(n)]
    target.pop(i)
    ans = max(ans, gcd_list(target))
print(ans)


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


def gcd_list(lst):
    a = lst[0]
    for i in lst[1:]:
        a = gcd(a, i)
    return a


n = int(eval(input()))
a = list(map(int, input().split()))
l = [0 for _ in range(n)]
r = [0 for _ in range(n)]
for i in range(n-1):
    l_i = 0 if 0 == i else l[i]
    l[i+1] = gcd(l_i, a[i])
for i in range(n)[::-1]:
    r_i1 = 0 if i == n-1 else r[i+1]
    r[i] = gcd(r_i1, a[i])
m = []
for i in range(n):
    r_i1 = 0 if i == n-1 else r[i+1]
    m.append(gcd(l[i], r_i1))
print((max(m)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
from collections import defaultdict
d=defaultdict(int)
op=set(make_divisors(a[0])+make_divisors(a[1]))
next_op=set()
for i in range(n):
    for opi in op:
        if a[i]%opi==0:
            d[opi]+=1
        if d[opi]>=i:
            next_op.add(opi)
    op=next_op
    next_op=set()
print((max(op)))


# 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
al=[]
ar=[]
tmp=a[0]
al.append(a[0])
for ai in a[1:]:
  tmp=gcd(ai,tmp)
  al.append(tmp)
ar.append(a[-1])
tmp=a[-1]
for ai in a[:-1][::-1]:
  tmp=gcd(ai,tmp)
  ar.append(tmp)
ans=ar[n-2]
for i in range(n-1):
  ans=max(ans,gcd(al[i],ar[n-i-3]))
ans=max(ans,al[n-2])
print(ans)
# Original solution
from collections import defaultdict

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

d = defaultdict(int)
s = set([])
def divisor(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            s.add(i)
            s.add(n // i)

for i in range(2):
    divisor(A[i])

for num in A:
    for key in s:
        if num % key == 0:
            d[key] += 1

ans = 1
for key, val in list(d.items()):
    if val >= N - 1:
        ans = max(ans, key)

print(ans)

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

def ABC125gcd(x, y):
    if min(x, y) == 0:
        return max(x, y)
    else:
        return ABC125gcd(y, x % y)

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

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

ans = 1
for i in range(N):
    ans = max(ans, ABC125gcd(L[i], R[i]))
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

from functools import reduce
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

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

m = 0
for i in range(N):
  if i == 0:
    tmp = A[1:]
  elif i == N-1:
    tmp = A[:N-1]
  else:
    tmp = A[:i] + A[i+1:]
  #print(tmp)
  a = gcd_list(tmp)
  if a > m:
    m = a

print(m)



# 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 = []
R = []

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

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

M = []
for i in range(N):
  if i == 0:
    M.append(R[N-2])
  elif i == N-1:
    M.append(L[N-2])
  else:
    M.append(gcd(L[i-1], R[N-2-i]))

print((max(M)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
def divisors(n):
    div = set()
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div.add(A)
            else:
                B = n//A
                div.add(A)
                div.add(B)
        A += 1
    return div
div = list(divisors(A[0]) | divisors(A[1]))
m = 0
for x in div:
    count = 0
    for a in A:
        if a%x != 0:
            count += 1
        if count > 1:
            break
    if count <= 1:
        m = max(m, x)
print(m)

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
def divisors(n):
    div = set()
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div.add(A)
            else:
                B = n//A
                div.add(A)
                div.add(B)
        A += 1
    return div
div = list(divisors(A[0]) | divisors(A[1]))
div.sort(reverse=True)
for x in div:
    count = 0
    for a in A:
        if a%x != 0:
            count += 1
        if count > 1:
            break
    if count <= 1:
        print(x)
        break
# Original solution
from math import gcd
from functools import reduce
n=int(eval(input()))
a=list(map(int,input().split()))
ans=reduce(gcd,a[1:])
ans=max(ans,reduce(gcd,a[:n-1]))
for i in range(1,n-1):
  ans=max(gcd(reduce(gcd,a[:i]),reduce(gcd,a[i+1:])),ans)
print(ans)

# Optimized solution
from math import*
n=int(eval(input()))
a=list(map(int,input().split()))
b=[a[0]]
c=[a[-1]]
for i in range(1,n):
  b+=[gcd(b[-1],a[i])]
  c+=[gcd(c[-1],a[-i-1])]
ans=0
c=c[::-1]
for i in range(n):
  if i==0:ans=max(ans,c[i+1])
  elif i==n-1:ans=max(ans,b[i-1])
  else:
    ans=max(ans,gcd(c[i+1],b[i-1]))
print(ans)
# Original solution
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


def gcd_ab(a,b):
  while a != b:
    if a > b:
      a,b = [b,a]
    if a == 0:
      return b
    b = b-a
  return a


if __name__ == "__main__": 
  N = int(eval(input()))
  An = list(map(int, sys.stdin.readline().rstrip().split()))
  cum = [[0,0] for i in range(N+2)]

  for i in range(N):
    cum[i+1][0] = gcd_ab(cum[i][0], An[i])
    cum[N-i][1] = gcd_ab(cum[N-i+1][1], An[N-i-1])

  ans = [0 for i in range(N)]
  for i in range(1,N+1):
    ans[i-1] = gcd_ab(cum[i-1][0], cum[i+1][1])
  print((max(ans)))


# Optimized solution
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


def gcd_ab(a,b):
  a,b = sorted([a,b])
  if a == 0:
    return b
  return gcd_ab(b%a, a)

if __name__ == "__main__": 
  N = int(eval(input()))
  An = list(map(int, sys.stdin.readline().rstrip().split()))
  cum = [[0,0] for i in range(N+2)]

  for i in range(N):
    cum[i+1][0] = gcd_ab(cum[i][0], An[i])
    cum[N-i][1] = gcd_ab(cum[N-i+1][1], An[N-i-1])

  ans = [0 for i in range(N)]
  for i in range(1,N+1):
    ans[i-1] = gcd_ab(cum[i-1][0], cum[i+1][1])
  print((max(ans)))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
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
divs = make_divisors(a[0]) #list

divsTF = [0]*len(divs)
for i in range(len(divs)):
    j = [1 if a[_] % divs[i] else 0 for _ in range(n) ]

    if sum(j) <= 1:
        divsTF[i] = 1

ans = 1
for i in range(len(divs)):
    if divsTF[i] == 1:
        ans = max(ans,divs[i])


divs2 = make_divisors(a[1]) #list

divsTF2 = [0]*len(divs2)
for i in range(len(divs2)):
    j = [1 if a[_] % divs2[i] else 0 for _ in range(n) ]

    if sum(j) <= 1:
        divsTF2[i] = 1

aans = 1
for i in range(len(divs2)):
    if divsTF2[i] == 1:
        aans = max(aans,divs2[i])
print((max(aans,ans)))

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
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
divs = list(set(make_divisors(a[0])+make_divisors(a[1]))) #list

divsTF = [0]*len(divs)
for i in range(len(divs)):
    j = [1 if a[_] % divs[i] else 0 for _ in range(n) ]

    if sum(j) <= 1:
        divsTF[i] = 1

ans = 1
for i in range(len(divs)):
    if divsTF[i] == 1:
        ans = max(ans,divs[i])
print(ans)
# Original solution
import math
import copy
from functools import reduce

def gcd(*numbers):
    def gcd(a, b):
        while b != 0:
            a, b = b, a % b
        return a
    return reduce(gcd, numbers)


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

a_max = 0
for i in range(N):
    new_a = copy.deepcopy(A)
    new_a.pop(i)
    a_max = max(a_max,gcd(*new_a))

print(a_max)


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

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

l_gcd = [-1] * N
r_gcd = [-1] * N

for i in range(N):
    if i == 0:
        l_gcd [0] = blackboard[0]
    else:
        l_gcd[i] = gcd(l_gcd[i-1],blackboard[i])


for i in reversed(list(range(N))):
    if i == N - 1:
        r_gcd[N-1] = blackboard[N-1]
    else:
        r_gcd[i] = gcd(r_gcd[i+1],blackboard[i])


#左端と右端のときの値を予め比較しておく。
ans = max(l_gcd[-2],r_gcd[1])

for i in range(1,N-1):
    ans = max(ans,gcd(l_gcd[i-1],r_gcd[i+1]))
print(ans)
# Original solution
import copy
N = int(eval(input()))
A = list(map(int, input().split()))

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

F = copy.copy(A)
B = copy.copy(A)

for i in range(1, N):
  F[i] = gcd(F[i], F[i-1])
for i in range(N - 2, -1, -1):
  B[i] = gcd(B[i+1], B[i])

mx = max(F[N-2], B[1])
for i in range(1, N - 1):
  mx = max(mx, gcd(F[i-1], B[i+1]))
print(mx)


# Optimized solution
import copy

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

N = int(eval(input()))
A = list(map(int, input().split()))
F = copy.copy(A)
B = copy.copy(A)
for i in range(N - 1):
  F[i + 1] = gcd(F[i + 1], F[i])
for i in range(N - 2, -1, -1):
  B[i] = gcd(B[i], B[i + 1])
ans = max(F[N-2], B[1])
for i in range(1, N - 1):
  ans = max(ans, gcd(F[i-1], B[i+1]))
print(ans)
# Original solution
import sys, copy

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y) #再帰定義

def listgcd(A):
	newA = []
	if len(A) % 2 == 1:
		A.append(0)
	
	for i in range(0, len(A), 2):
		newA.append(gcd(A[i], A[i + 1]))
	
	if len(newA) == 1:
		return newA[0]
	else:
		return listgcd(newA)
	
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

ans = 0

for i in range(N):
	B = copy.copy(A)
	B[i] = 0
	tmp = listgcd(B)
	if ans < tmp:
		ans = tmp
		
print(ans)


# Optimized solution
import sys

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y) #再帰定義
	
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

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

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

for i in range(N):
	tmp = gcd(L[i], R[N - 1 - i])
	if tmp > ans:
		ans = tmp
		
print(ans)
# Original solution
def gcd(a,b):
    if ( b==0 ):
        return a
    else:
        return (gcd(b, a%b))

def reduce_gcd(lst):
    ans = lst.pop(0)
    for i in lst:
        ans = gcd(ans,i)
    return ans

def other_lst(lst,index):
    return [x for i,x in enumerate(lst) if not i == index]

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

print((max([reduce_gcd(other_lst(A,i)) for i in range(len(A)) ])))

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

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

left_gcd = [A[0]]
for i in A[1:]:
    left_gcd.append(gcd(left_gcd[-1],i))

right_gcd = [A[-1]]
for i in reversed(A[0:-1]):
    right_gcd.append(gcd(right_gcd[-1],i))
right_gcd.reverse()

gcd_lst = [right_gcd[1]] + [gcd(right_gcd[i+1], left_gcd[i-1]) for i in range(1,len(A)-1)] + [left_gcd[-2]]
print((max(gcd_lst)))
# Original solution
from math import gcd
from copy import copy
#================================================
def GCD(A):
    n=len(A)
    if n==1:
        return A[0]

    return gcd(GCD(A[:n//2]),GCD(A[n//2:]))
#================================================
N=int(eval(input()))
A=list(map(int,input().split()))
B=copy(A)

M=0
for i in range(N):
    B[i]=0
    M=max(M,GCD(B))
    B[i]=A[i]

print(M)

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

F=[0]*N
G=[0]*N

F[0]=A[0]
G[-1]=A[-1]

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

F=[0]+F+[F[-1]]
G=[G[0]]+G+[0]

M=0
for i in range(N):
    M=max(M,gcd(F[i],G[i+2]))
print(M)
# Original solution
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def main():

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

    N, *A = list(map(int, sys.stdin.read().split()))
    L = [0] * (N + 2)
    R = [0] * (N + 2)
    for i in range(N):
        L[i + 2] = gcd(L[i + 1], A[i])
        R[-i - 2] = gcd(R[-i - 1], A[-i - 1])

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

if __name__=='__main__':
  main()

# Optimized solution
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def main():

    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

    N, *a = list(map(int, sys.stdin.read().split()))
    p=50
    if p>N: p=N

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

if __name__=='__main__':
  main()
# Original solution
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def main():

    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

    N, *a = list(map(int, sys.stdin.read().split()))
    p=50
    if p>N: p=N

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

if __name__=='__main__':
  main()

# Optimized solution
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def main():

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

    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

    N, *a = list(map(int, sys.stdin.read().split()))
    p=50
    if p>N: p=N

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

if __name__=='__main__':
  main()
# Original solution
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)

def main():
    @lru_cache(maxsize=None)
    def gcd(a, b):
        if a % b == 0:
            return b
        else:
            return gcd(b, a % b)

    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

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

if __name__=='__main__':
    N, *a = list(map(int, sys.stdin.read().split()))
    p=50
    if p>N: p=N
    main()

# Optimized solution
import sys
sys.setrecursionlimit(1000000)

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

    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

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

if __name__=='__main__':
    N, *a = list(map(int, sys.stdin.read().split()))
    p=50
    if p>N: p=N
    main()
# Original solution
from functools import lru_cache, reduce
from bisect import bisect
n = int(eval(input()))
aa = list(map(int, input().split()))

lencache = []
cache = []

@lru_cache(maxsize=10**9)
def gcd2(a, b) :
    if a%b : return gcd2(b, a%b)
    else : return b

@lru_cache(maxsize=10**9)
def gcdn(fs) :
    global cache, lencache
    l = len(fs)
    i = bisect(lencache, l)
    lencache.insert(i, l)
    cache.insert(i, fs)
    if l == 1 :
        return list(fs)[0]
    elif l < 10 :
        return reduce(gcd2, fs)
    else :
        for c in cache[::-1] :
            if c in fs :
                return gcd2(gcdn(c), gcdn(fs-c))
        else :
            c = frozenset({v for i, v in enumerate(fs) if i<len(fs)/2})
            return gcd2(gcdn(c), gcdn(fs-c))

m = 1
for i in range(n) :
    s = frozenset(aa[:i]+aa[i+1:])
    g = gcdn(s)
    if g > m :
        m = g
else :
    print(m)

# Optimized solution
from functools import lru_cache
n = int(eval(input()))
aa = list(map(int, input().split()))

@lru_cache(maxsize=10**9)
def gcd(a, b) :
    if b == 0 : return a
    elif a%b : return gcd(b, a%b)
    else : return b

l = [0]
r = [0]
for i in range(n) :
    l.append(gcd(l[-1], aa[i]))
    r.append(gcd(r[-1], aa[-i-1]))

m = [gcd(l[i],r[-i-2]) for i in range(n)]
print((max(m)))
# Original solution
from functools import reduce


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


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


def main():
    N, *A = list(map(int, open(0).read().split()))
    print((max(gcd_n(A[:i] + A[i + 1:]) for i in range(N))))
    return


main()


# Optimized solution
def gcd(a, b):
    if not a:
        # a が ゼロ ならば b
        return b
    if not b:
        # b が ゼロ ならば a
        return a
    while b:
        a, b = b, a % b
    return a


def main():
    N, *A = list(map(int, open(0).read().split()))
    L = [0] * N
    R = L[:]
    R.append(0)
    for i in range(N - 1):
        L[i + 1] = gcd(L[i], A[i])
    for i in range(N - 1, -1, -1):
        R[i] = gcd(R[i + 1], A[i])
    print((max(gcd(L[i], R[i + 1]) for i in range(N))))
    return


main()
# Original solution
# coding: utf-8
# Your code here!

def euclid(a,b):
    a,b=max(a,b),min(a,b)
    if a%b==0:
        return b
    else:
        a,b=b,a%b
        return euclid(a,b)

N=int(eval(input()))
A=list(map(int,input().split()))
org_A=A[:]
#左から最大公約数作る右もね
ans=0
for i in range(N):
    l=A[:i]
    for j in range(len(l)-1):
        l[j+1]=euclid(l[j+1],l[j])
    
    r=A[i+1:]
    for j in range(len(r)-1):
        r[-j-2]=euclid(r[-j-1],r[-j-2])
        
    ans=max(ans,euclid(r[0] if len(r)>0 else l[-1],l[-1] if len(l)>0 else r[0]))
    
print(ans)

# Optimized solution
# coding: utf-8
# Your code here!
def euclid(a,b):
    a,b=max(a,b),min(a,b)
    if a%b==0:
        return b
    else:
        a,b=b,a%b
        return euclid(a,b)

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

org_A=A[:]
#左から最大公約数作る右もね
A=A[::-1]
l=[A.pop(-1)]
while A:
    l.append(euclid(l[-1],A.pop(-1)))

A=org_A
r=[A.pop(-1)]
while A:
    r.append(euclid(r[-1],A.pop(-1)))
r=r[::-1]

ans=0
#print(l,r)
for i in range(N):
    temp=euclid(l[i-1] if i!=0 else r[i+1],r[i+1] if i!=N-1 else l[i-1])
    #print(l[i-1] if i!=0 else r[i+1],r[i+1] if i!=N-1 else l[i-1])
    ans=max(ans,temp)

print(ans)
# Original solution
import math
import functools
import copy

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

for i in range(N):
  del b[i]
  gcd=functools.reduce(math.gcd,b)
  ans.append(gcd)
  b.insert(i,a[i])

print((max(ans)))

# Optimized solution
import math
from itertools import accumulate

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

fromleft = list(accumulate(a, math.gcd))
fromright = list(accumulate(a[::-1], math.gcd))[::-1]

gcd = []

gcd.append(fromright[1])
for i in range(1, n-1):
    gcd.append(math.gcd(fromleft[i-1], fromright[i+1]))
gcd.append(fromleft[n-2])

print((max(gcd)))