CodeEff/ECCO huggingface dataset:
# Original solution
from functools import reduce
import copy
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y) #再帰定義
  
def gcd_list(numbers):
    return reduce(gcd, numbers)
  
n=int(eval(input()))
a_o=list(map(int,input().split()))
g=[1]*n
for i in range(n):
  a=copy.copy(a_o)
  a.pop(i)
  g[i]=gcd_list(a)
print((max(g)))

# Optimized solution
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y) #再帰定義
n=int(eval(input()))
a=list(map(int,input().split()))
l=[0]*n
r=[0]*n
for i in range(1,n):
  if i==1:
    l[1]=a[0]
    r[-2]=a[-1]
  else:
    l[i]=gcd(l[i-1],a[i-1])
    r[-i-1]=gcd(r[-i],a[-i])
g=[0]*n
for i in range(n):
  if l[i]==0 or r[i]==0:
    g[i]=l[i]+r[i]
  else:
    g[i]=gcd(l[i],r[i])
print((max(g)))
# Original solution
def gcd(a,b):
    if a % b == 0:
        return b
    else:
        return gcd(b,a%b)

N = int(eval(input()))
A = [i for i in map(int,input().split())]
g = []
for i in range(N):
    ans = 0
    for j in range(N):
        if ans == 0 and i != j:
            ans = A[j]
            continue
        if i != j:
            ans = gcd(A[j],ans)
    g.append(ans)
print((max(g)))

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

N = int(eval(input()))
A = [i for i in map(int,input().split())]
L = [0]
R = [0]
for i in range(N):
    L.append(gcd(L[-1],A[i]))
for i in range(N-1,-1,-1):
    R.append(gcd(R[-1],A[i]))
R.reverse()
g = []
for i in range(N):
    g.append(gcd(L[i],R[i+1]))
print((max(g)))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))

if n == 2:
    print((max(a)))
else:
    l = [-1]
    r = []
    
    def gcd(x,y):
        while y != 0:
            x, y = y, x%y
    #        print(x,y)
        return(x)
    
    for i in range(n-1):
        m = a[i+1:][0]
        if len(a[i+1:]) == 1:
            m = a[i+1:][0]
        elif len(a[i+1:]) > 1:
            for j in a[i+1:]:
                m = gcd(m,j)
        r.append(m)
        m2 = a[:i+1][0]
        if len(a[:i+1]) == 1:
            m2 = a[:i+1][0]
        elif len(a[:i+1]) > 1:
            for j in a[:i+1]:
                m2 = gcd(m2,j)
        l.append(m2)
    r.append(-1)
 #   print(r)
  #  print(l)
    ans = 0
    for i in range(n):
        if l[i] == -1:
            ans = max(ans,r[i])
        elif r[i] == -1:
            ans = max(ans,l[i])
        else:
            ans = max(ans,gcd(l[i],r[i]))
    print(ans)

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

if n == 2:
    print((max(a)))
else:
    l = [0 for i in range(n)]
    r = [0 for i in range(n)]
    
    def gcd(x,y):
        while y != 0:
            x, y = y, x%y
    #        print(x,y)
        return(x)
    
    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])
  #  print(l)
  #  print(r)
    ans = 0
    for i in range(n):
        if l[i] == -1:
            ans = max(ans,r[i])
        elif r[i] == -1:
            ans = max(ans,l[i])
        else:
            ans = max(ans,gcd(l[i],r[i]))
    print(ans)
# Original solution
N=int(eval(input()))
LA=list(map(int,input().split()))
ans=[]

def gcd(m,n):
    while n:
        m,n=n,m%n
    return m

from functools import reduce
def multigcd(item):
    return reduce(gcd, item)

for n in range(N):
    L=LA[:n]+LA[n+1:]
    ans.append(multigcd(L))

print((max(ans)))

# Optimized solution
N=int(eval(input()))
LA=list(map(int,input().split()))
ans=[]

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

La=[0]
Lb=[0]

for n in range(N-1):
    La.append(gcd(La[n],LA[n]))
    Lb.append(gcd(Lb[n],LA[-(n+1)]))

for n in range(N):
    ans.append(gcd(La[n],Lb[-(n+1)]))
        
print((max(ans)))
# Original solution
#import math
from functools import reduce

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

    return a


n = int(eval(input()))
a = [int(i) for i in input().split()]
L = [0] * n

for i in range(n):
    aa = a[:]
    aa.pop(i)
    L[i] = reduce(gcd, aa)

print((max(L)))


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


n = int(eval(input()))
A = [int(i) for i in input().split()]

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

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

M = [gcd(L[i],R[i]) for i in range(n)]

print((max(M)))
# Original solution
import sys
from collections import deque

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

input = sys.stdin.readline
n = int(eval(input()))
a_que = deque(list(map(int, input().split())))
ans = 1
for _ in range(n):
    out = a_que.popleft()
    m = 0
    for a in a_que:
        m = gcd(m, a)
    ans = max(ans, m)
    a_que.append(out)
print(ans)


# Optimized solution
import sys

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

input = sys.stdin.readline
n = int(eval(input()))
a_list = list(map(int, input().split()))
l_list = [0]
r_list = [0]
l_gcd, r_gcd = 0, 0
for i in range(n-1):
    l_gcd = gcd(l_gcd, a_list[i])
    l_list.append(l_gcd)
    r_gcd = gcd(r_gcd, a_list[-i-1])
    r_list.append(r_gcd)
ans = 1
for i in range(n):
    ans = max(ans, gcd(l_list[i], r_list[-i-1]))
print(ans)
# Original solution

n = int(eval(input()))

a = list(map(int, input().split()))
a.sort(reverse=True)


from functools import lru_cache
import sys
if n == 2:
    print((max(a)))
    sys.exit()


@lru_cache(maxsize=100000)
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


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


def gcd_list_2(li):
    g = gcd(li[0], li[1])
    if g == 1:
        return max(gcd_list([li[0]] + li[2:]), gcd_list(li[1:]))
    for i in range(2, n):
        if gcd(g, li[i]) == 1:
            if i == n - 1:
                return gcd_list(li[:i])
            gg = gcd_list(li[i+1:])
            bb = [gcd(li[x], gg) for x in range(i+1)]
            bb.sort()
            return bb[1]
        else:
            g = gcd(g, li[i])
    return g


def max_gcd(a):
    g = gcd_list(a)
    a = [a[i]//g for i in range(n)]
    m = gcd_list_2(a)
    print((g * m))


max_gcd(a)

# Optimized solution

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


import sys
if n == 2:
    print((max(a)))
    sys.exit()


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


g = a[0]
gcd_left = [g]
for i in range(n-1):
    g = gcd(g, a[i+1])
    gcd_left.append(g)

g = a[n-1]
gcd_right = [g]
for i in range(n-1):
    g = gcd(g, a[n-2-i])
    gcd_right.append(g)

max_gcd = gcd_right[n-2]
for i in range(1, n-1):
    max_gcd = max(max_gcd, gcd(gcd_left[i-1], gcd_right[n - 2 - i]))
max_gcd = max(max_gcd, gcd_left[n-2])

print(max_gcd)
# Original solution
import math
N = int(eval(input()))
A = [int(_) for _ in input().split()]


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif y == 0:
        return x
    else:
        return gcd(y, x % y)


class SegmentTree():
    def m(self, v1, v2):  # ***monoid***
        return gcd(v1, v2)

    def __init__(self, array):
        m = self.m
        e = self.e = 0  # ***identity element***
        size = self.size = 10**6  # ***limit for array size***
        n = self.n = len(array)
        dat = self.dat = [e] * n + array + [e] * (2 * size - 2 * n)
        for i in range(n - 1, 0, -1):  # build
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):  # set value at position p (0-indexed)
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


ST = SegmentTree(A)
ans = 0
for i, a in enumerate(A):
    ST.modify(i, ST.e)
    ans = max(ans, ST.query(0, N))
    ST.modify(i, a)
print(ans)


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


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif y == 0:
        return x
    else:
        return gcd(y, x % y)


class SegmentTree():
    def m(self, v1, v2):  # ***monoid***
        return gcd(v1, v2)

    def __init__(self, array):
        m = self.m
        e = self.e = 0  # ***identity element***
        size = self.size = 10**5  # ***limit for array size***
        n = self.n = len(array)
        dat = self.dat = [e] * n + array + [e] * (2 * size - 2 * n)
        for i in range(n - 1, 0, -1):  # build
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):  # set value at position p (0-indexed)
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


ST = SegmentTree(A)
ans = 0
for i, a in enumerate(A):
    ST.modify(i, ST.e)
    ans = max(ans, ST.query(0, N))
    ST.modify(i, a)
print(ans)
# Original solution
N = int(eval(input()))
A = [int(_) for _ in input().split()]


class SegmentTree():
    def __init__(self, array, m, e, size):
        self.m = m  # monoid
        self.e = e  # identity element
        self.size = size  # limit for array size
        self.n = n = len(array)  # array size
        self.dat = dat = [e] * n + array + [e] * (2 * size - 2 * n)
        for i in range(n - 1, 0, -1):  # build
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):  # set value at position p (0-indexed)
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


gcd = lambda x, y: gcd(y, x) if x < y else x if y == 0 else gcd(y, x % y)
e = 0
size = 10**6
ST = SegmentTree(A, m=gcd, e=e, size=size)

ans = 1
for i, a in enumerate(A):
    ST.modify(i, 0)
    ans = max(ans, ST.query(0, N))
    ST.modify(i, a)
print(ans)


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


class SegmentTree():
    def __init__(self, array, m, e, size):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        m : func
            binary operation of the monoid
        e : 
            identity element of the monoid
        size : int
            limit for array size
        """
        self.m = m
        self.e = e
        self.size = size
        self.n = n = len(array)
        self.dat = dat = [e] * n + array + [e] * (2 * size - 2 * n)
        for i in range(n - 1, 0, -1):  # build
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):  # set value at position p (0-indexed)
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


gcd = lambda x, y: gcd(y, x) if x < y else x if y == 0 else gcd(y, x % y)
e = 0
size = N
ST = SegmentTree(A, m=gcd, e=e, size=size)
ans = 1
for i, a in enumerate(A):
    ST.modify(i, 0)
    ans = max(ans, ST.query(0, N))
    ST.modify(i, a)
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 gcd_of_arr(arr):
    cd = arr[0]
    for i in range(1,len(arr)):
        if cd==1:
            return cd
        cd = gcd(arr[i], cd)
    return cd

ans = 0
for i in range(N):
    tmp = gcd_of_arr(A[0:i] + A[i+1:N])
    ans = max(ans, tmp)

print(ans)


# 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 = [0]*(N+1), [0]*(N+1)
for i in range(1,N+1):
    L[i] = gcd(L[i-1], A[i-1])
    R[N-i] = gcd(R[N+1-i], A[N-i])

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

print(ans)
# Original solution
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter
    from functools import lru_cache
    #inf = 10**17
    #mod = 10**9 + 7

    N = int(eval(input()))
    A = list(map(int, input().split()))
    @lru_cache(maxsize=None)
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    
    if len(A) == 2:
        print((max(A)))
        exit()
    res = 0
    for i in range(N):
        arr = A[:i] + A[i+1:]
        res = max(res, gcd_group(arr))
    print(res)

if __name__ == '__main__':
    main()


# Optimized solution
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter
    #inf = 10**17
    #mod = 10**9 + 7

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

    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    
    l = [0]
    for i in range(N-1):
        l.append(gcd(l[-1], A[i]))
    r = [0]
    for i in range(N-1, 0, -1):
        r.append(gcd(r[-1], A[i]))
    
    res = 0
    for i in range(N):
        res = max(res, gcd(l[i], r[-(i+1)]))
    print(res)


if __name__ == '__main__':
    main()
# Original solution
import math
import itertools

n = int(eval(input()))
a = list(map(int, input().split()))
pf = [0]*(n+1)
pb = [0]*(n+1)
p = a[0]
for i in range(n):
  p = math.gcd(p, a[i])
  pf[i+1] = p
p = a[-1]
for i in range(-1, -n-1, -1):
  p = math.gcd(p, a[i])
  pb[i-1] = p
ans = [0]*n
for i in range(n):
  ans[i] = math.gcd(pf[i], pb[i+1])
print((max(ans)))

# Optimized solution
import math
import itertools

n = int(eval(input()))
a = list(map(int, input().split()))
pf = [0] + list(itertools.accumulate(a, math.gcd))
pb = [0] + list(itertools.accumulate(reversed(a), math.gcd))
pb.reverse()
ans = [0]*n
for i in range(n):
  ans[i] = math.gcd(pf[i], pb[i+1])
print((max(ans)))
# Original solution
import collections
from functools import reduce

def gcd(u,v):
	if v:
		return gcd(v, u % v)
	else:
		return u

n = int(input())
elems = list(map(int , input().split(' ')))
dpp = [ None ] * len(elems)
dps = [ None ] * len(elems)
for i in range(len(elems)): dpp[i] = reduce(gcd, elems[:i+1])
for i in range(len(elems)): dps[len(elems) - 1 - i] = reduce(gcd, elems[- i - 1:])

r = 0
for i in range(len(elems)):
	u,v = dpp[i-1] if i-1 >= 0 else -1, dps[i+1] if i+1 < len(elems) else -1
	r  = max(r, gcd(u,v) if u != -1 and v != -1 else max(u,v))
print(r)



# Optimized solution
import collections

def gcd(u,v):
	if v:
		return gcd(v, u % v)
	else:
		return u

n = int(input())
elems = list(map(int , input().split(' ')))
dpp = [ None ] * len(elems)
dps = [ None ] * len(elems)
dpp[0] = elems[0]
for i in range(1,len(elems)): 
	dpp[i] = gcd(elems[i], dpp[i-1])
dps[len(elems) -1]  = elems[-1]
for i in range(len(elems) - 2, -1, -1): 
	dps[i] = gcd(elems[i], dps[i+1])
r = 0
for i in range(len(elems)):
	u,v = dpp[i-1] if i-1 >= 0 else -1, dps[i+1] if i+1 < len(elems) else -1
	r  = max(r, gcd(u,v) if u != -1 and v != -1 else max(u,v))
print(r)
# Original solution
def gcd(m,n):
  x=max(m,n)
  y=min(m,n)
  if x==0:
    return 0
  while y!=0:
    x,y=y,x%y
  return x
 
n = int(eval(input()))
a = list(map(int, input().split()))
b = [0]
 
for i in range(n):
  a[i],a[n-1]=a[n-1],a[i]
  temp = a[0]
  for j in range(n-1):
    temp=gcd(temp,a[j])
    if temp == 1:
      break
    if temp < max(b):
      break
  b.append(temp)
  a[i],a[n-1]=a[n-1],a[i]
  
print((max(b)))


# Optimized solution
def gcd(m,n):
  x=max(m,n)
  y=min(m,n)
  while y!=0:
    x,y=y,x%y
  return x

n = int(eval(input()))
a = list(map(int, input().split()))
b = []
l = [0]
r = [0]

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

for i in range(n):
  b.append(gcd(l[i],r[n-1-i]))
  
print((max(b)))
# Original solution
from math import gcd


N, *A = list(map(int, open(0).read().split()))

acc_l = [0] * (N + 1)
acc_r = [0] * (N + 1)
for i in range(1, N + 1):
    acc_l[i] = gcd(acc_l[i - 1], A[i - 1])
    acc_r[i] = gcd(acc_r[i - 1], A[-i])
ans = 0
for i in range(N + 1):
    ans = max(ans, gcd(acc_l[i], acc_r[N - i - 1]))
print(ans)


# Optimized solution
from math import gcd


N, *A = list(map(int, open(0).read().split()))
acc_l = [0]
acc_r = [0]
for i in range(N):
    acc_l.append(gcd(acc_l[-1], A[i]))
    acc_r.append(gcd(acc_r[-1], A[N - i - 1]))

ans = 0
for i in range(N):
    ans = max(ans, gcd(acc_l[i], acc_r[N - i - 1]))
print(ans)
# Original solution
def gcd(a, b):
    while True:
        a, b = b, a % b
        if b == 0:
            break
    return a


def compute_gcd(ns):
    a = gcd(ns[0], ns[1])
    for i in range(2, len(ns)):
        a = gcd(a, ns[i])
    return a


n = int(eval(input()))
nums = list(map(int, input().split()))
if n == 2:
    print((max(nums)))
else:
    gcds = []
    for i in range(n):
        ns = [nums[j] for j in range(n) if j != i]
        a = compute_gcd(ns)
        gcds.append(a)
    print((max(gcds)))

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


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

if n == 2:
    print((max(nums)))
else:
    l_gcds = [nums[0]]
    r_gcds = [nums[-1]]
    for i in range(1, n - 1):
        l = gcd(l_gcds[-1], nums[i])
        r = gcd(r_gcds[-1], nums[n - i - 1])
        l_gcds.append(l)
        r_gcds.append(r)
    r_gcds = r_gcds[::-1]
    gcds = [l_gcds[-1], r_gcds[0]]
    for i in range(1, n - 1):
        gcds.append(gcd(l_gcds[i - 1], r_gcds[i]))
    print((max(gcds)))
# Original solution
N=int(eval(input()))
nums = [int(i) for i in input().split()]

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

memo = {}
memo[(0, 1)] = nums[0]
memo[(N-1, N)] = nums[N-1]

for i in range(2, N+1):
    memo[(0, i)] = gcd(memo[(0, i - 1)], nums[i-1])
    # print("{} {} memo:{}".format(0, i, memo[(0,i)]))


for i in reversed(list(range(0, N-1))):
    memo[(i, N)] = gcd(memo[(i + 1, N)], nums[i])
    # print("{} {} memo:{}".format(i, N, memo[(i,N)]))

res = 1
for i in range(1, N-1):
    res = max(res, gcd(memo[(0, i)], memo[(i+1, N)]))
    # print("gcd:{}".format(gcd(memo[(0, i)], memo[(i+1, N)])))

res = max(res, memo[(0, N-1)])
res = max(res, memo[(1, N)])

print(res)


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

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

memo = {}
memo[(0, 1)] = nums[0]
memo[(N-1, N)] = nums[N-1]

for i in range(2, N+1):
    memo[(0, i)] = gcd(memo[(0, i - 1)], nums[i-1])

for i in reversed(list(range(0, N-1))):
    memo[(i, N)] = gcd(memo[(i + 1, N)], nums[i])

res = 1
for i in range(1, N-1):
    res = max(res, gcd(memo[(0, i)], memo[(i+1, N)]))

res = max(res, memo[(0, N-1)])
res = max(res, memo[(1, N)])

print(res)
# Original solution
N = int(eval(input()))
A = [int(n) for n in input().split()]

import math, copy

def all_gcd(l):
    a = l[0]
    for i in range(1,len(l)):
        b = l[i]
        a = math.gcd(a, b)
    return a

max_gcd = 0
for n in A:
    copied_A = copy.copy(A)
    copied_A.remove(n)
    max_gcd = max(max_gcd, all_gcd(copied_A)) 

print(max_gcd) 

# Optimized solution
import math

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

gcd_l = [0]
gcd_r = [0]


for i in range(N):
    gcd_l.append(math.gcd(gcd_l[i], A[i]))
    gcd_r.append(math.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]

max_gcd = 0
for i in range(N):
    max_gcd = max(max_gcd, math.gcd(gcd_l[i], gcd_r[i+1]))

print(max_gcd)
# Original solution
import math
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()))

if N==2:
    print((max(A)))
    exit()
else:
    max=0
    for i in range(N):
        x = copy.deepcopy(A)
        del x[i]
        element = gcd(x[0], x[1])
        if N==2:
            c = element
        else:
            for i in range(2,N-1):
                element=gcd(element,x[i])
            c = element
        if c >= max:
            max = c
print(max)


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

AL=[0]*N
AR=[0]*N
for i in range(N):
    if i == 0:
        AL[0] = A[0]
        AR[0] = A[N-1]
    else:
        AL[i] = gcd(AL[i-1],A[i])
        AR[i] = gcd(AR[i-1],A[N-i-1])

max=0
for i in range(N):
    if i == 0:
        n_ex_gcd =  AR[N-2]
    elif i == N-1:
        n_ex_gcd = AL[N-2]
    else:
        n_ex_gcd = gcd(AL[i-1],AR[N-i-2])
    if n_ex_gcd > max:
        max = n_ex_gcd
print(max)