CodeEff/ECCO huggingface dataset:
# Original solution
def 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

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

    res = {}
    for a in A:
        for divisor in divisors(a):
            if divisor not in res:
                res[divisor] = 1
            else:
                res[divisor] += 1

    print((max([key for key, value in list(res.items()) if value == N or value == N - 1])))


if __name__ == '__main__':
    main()

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

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

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

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


if __name__ == '__main__':
    main()
# Original solution
from collections import Counter

def getDivisor(x):
    ans = []
    for d in range(1, int(x**0.5)+1):
        if x % d == 0:
            ans.append(d)
            if x//d != d:
                ans.append(x//d)
    return sorted(ans)

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

divisors = getDivisor(As[0]) + getDivisor(As[1])
cnt = Counter(divisors)

for i, A in enumerate(As[2:], 2):
    for d, num in list(cnt.items()):
        if A%d == 0:
            cnt[d] += 1

    for d, num in list(cnt.items()):
        if num < i:
            del cnt[d]

print((max(cnt.keys())))


# Optimized solution
from itertools import accumulate

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

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

Ls = [As[-1]] + list(accumulate(As, gcd))
Rs = list(accumulate(As[::-1], gcd))[::-1] + [As[0]]

ans = 0
for i in range(N):
    g = gcd(Ls[i], Rs[i+1])
    ans = max(ans, g)
print(ans)
# Original solution
def gcd(x, y):
    if x > y:
        tmp = x
        x = y
        y = tmp
    if x == 0:
        return y
    else:
        return gcd(y%x, x)

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

# if N == 2:
#     print(max(A[0], A[1]))
#     return 0

Llist = [0]
Rlist = [0]

for i in range(N):
    Llist.append(gcd(Llist[i], A[i])) 
    Rlist.insert(0, gcd(Rlist[0], A[N-1-i]))

ans = 0
for i in range(N):
    t = gcd(Llist[i], Rlist[i+1])
    if ans < t:
        ans = t

print(ans)


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

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

Llist = [0]
Rlist = [0]

for i in range(N):
    Llist.append(gcd(Llist[i], A[i])) 
    # Rlist.insert(0, gcd(Rlist[0], A[N-1-i]))
    Rlist.append(gcd(Rlist[i], A[N-1-i]))
Rlist = Rlist[::-1]
ans = 0
for i in range(N):
    t = gcd(Llist[i], Rlist[i+1])
    if ans < t:
        ans = t

print(ans)
# Original solution
import copy
n = int(eval(input()))
x = [int(i) for i in input().split()]

#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


def gcd_multi(n,x):
    if n==1:
        return x[0]
    else:
        element = gcd(x[0], x[1])
        if n==2:
            return element
        else:
            for i in range(2,n):
                element=gcd(element,x[i])
            return element

ans = []
for i in range(n):
    l = copy.deepcopy(x)
    del l[i]
    ans.append(gcd_multi(n-1,l))

print((max(ans)))


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

#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


def gcd_multi(n,x):
    if n==1:
        return x[0]
    else:
        element = gcd(x[0], x[1])
        if n==2:
            return element
        else:
            for i in range(2,n):
                element=gcd(element,x[i])
            return element

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],x[i-1])

for i in range(n-1)[::-1]:
    Y[i]=gcd(Y[i+1],x[i+1])

Z=[gcd(X[i],Y[i]) for i in range(n)]
print((max(Z)))
# Original solution
import sys
sys.setrecursionlimit(10**6)

n = int(eval(input()))
a = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ans = 1

from math import gcd

for i in range(n):
    tmp = -1
    for j in range(n):
        if i != j:
            if tmp == -1:
                tmp = a[j]
            else:
                tmp = gcd(tmp, a[j])
    ans = max(ans, tmp)

print(ans)

# Optimized solution
"""
累積GCD
"""

import sys
sys.setrecursionlimit(10**6)

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

from math import gcd

L = [0] * n
R = [0] * n

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

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

print(ans)
# Original solution
def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    gcd_L = [0]*(N+1)
    gcd_R = [0]*(N+1)

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

    for i, a in enumerate(A):
        gcd_L[i+1] = gcd(gcd_L[i], a)
    for i, a in enumerate(A[::-1], start=1):
        gcd_R[-(i+1)] = gcd(gcd_R[-i], a)
    ans = 0
    for i in range(N):
        cur = gcd(gcd_L[i], gcd_R[i+1])
        ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    gcd_L = [0]*(N+2)
    gcd_R = [0]*(N+2)

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

    for i, a in enumerate(A):
        gcd_L[i+1] = gcd(gcd_L[i], a)
    for i, a in enumerate(A[::-1], start=1):
        gcd_R[-(i+1)] = gcd(gcd_R[-i], a)
    gcd_R[0] = gcd_R[1]
    gcd_L[-1] = gcd_L[-2]
    # print(gcd_L, gcd_R)
    ans = 0
    for i in range(1, N+1):
        cur = gcd(gcd_L[i-1], gcd_R[i+1])
        ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
from collections import Counter

N = int(eval(input()))

#約数を列挙
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

A_list = [make_divisors(int(e)) for e in input().split()]

all_divisors_list=[]
for i in A_list:
  all_divisors_list += i

collected_adl = Counter(all_divisors_list)

ans = 1
for a in collected_adl.most_common():
  if a[1] <= N-2:
    break
  elif a[0]>ans:
    ans=a[0]
    
print(ans)

# Optimized solution
from collections import Counter
from functools import lru_cache

N = int(eval(input()))

#約数を列挙
@lru_cache(maxsize=1000)
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

A_list = [make_divisors(int(e)) for e in input().split()]

all_divisors_list=[]

for i in A_list:
  all_divisors_list += i

collected_adl = Counter(all_divisors_list)

ans = 1
for a in collected_adl.most_common():
  if a[1] <= N-2:
    break
  elif a[0]>ans:
    ans=a[0]
    
print(ans)
# Original solution
import sys
from functools import reduce

input = sys.stdin.readline

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

def gcds(nums):
    return reduce(gcd, nums)

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

ans = 0
for i in range(len(a)):
    if i == 0:
        l = 0
    else:
        l = gcds(a[:i])
    if i == len(a)-1:
        r = 0
    else:
        r = gcds(a[(i+1):])
    aaa = gcd(l, r)
    if ans < aaa:
        ans = aaa
print(ans)

# Optimized solution
import sys
from functools import reduce

input = sys.stdin.readline

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

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


ans = 0
l = [0]*(n+1)
r = [0]*(n+1)
for i in range(n):
    l[i+1] = gcd(l[i], a[i])
    r[n-i-1] = gcd(r[n-i], a[n-i-1])
for i in range(n):
    ans = max(ans, gcd(l[i], r[i+1]))
print(ans)
# Original solution
# AtCoder Beginner Contest 125
# https://atcoder.jp/contests/abc125
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

cache = {}


def gcd(a, b):
    if a not in cache:
        cache[a] = {}
    if b in cache[a]:
        return cache[a][b]
    if b == 0:
        cache[a][b] = a
        return a
    n = gcd(b, a % b)
    cache[a][b] = n
    return n

def main(N, An):
    if N == 2:
        n = max(An[0], An[1])
        print(n)
        return
    nn = [An[0]] * N
    nn[0] = An[1]
    for i in range(1, N):
        for j in range(N):
            if i == j:
                continue
            nn[j] = gcd(nn[j], An[i])
    print((int(max(nn))))

N = i2n()
An = i2nn()
main(N, An)


# Optimized solution
# AtCoder Beginner Contest 125
# https://atcoder.jp/contests/abc125
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

cache = {}


def gcd(a, b):
    if a not in cache:
        cache[a] = {}
    if b in cache[a]:
        return cache[a][b]
    if b == 0:
        cache[a][b] = a
        return a
    n = gcd(b, a % b)
    cache[a][b] = n
    return n

def main_lte(N, An):
    if N == 2:
        n = max(An[0], An[1])
        print(n)
        return
    nn = [An[0]] * N
    nn[0] = An[1]
    for i in range(1, N):
        for j in range(N):
            if i == j:
                continue
            nn[j] = gcd(nn[j], An[i])
    print((int(max(nn))))

def main(N, An):
    if N == 2:
        n = max(An[0], An[1])
        print(n)
        return
    nn0 = gcd(An[0], An[1])
    nn1 = set((An[0], An[1]))
    for i in range(2, N):
        t1 = nn0
        nn0 = gcd(nn0, An[i])
        t2 = [gcd(n, An[i]) for n in nn1]
        nn1 = set(t2)
        nn1.add(t1)
    n = max(nn1)
    print((int(n)))

N = i2n()
An = i2nn()
main(N, An)
# Original solution
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def gcd_array(A):
    n = len(A)
    s = A[0]
    i = 1
    while(i < n):
        s = gcd(s,A[i])
        i += 1
    return s

if __name__ == "__main__":
    N = int(eval(input()))
    B = list(map(int,input().split()))
    max = 0
    i = 0
    while(i < N):
        A = [i for i in B]
        A.pop(i)
        d = gcd_array(A)
        if max <= d:
            max = d
        i += 1
    print(max)

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

def gcd_array(A):
    n = len(A)
    s = A[0]
    i = 1
    Down = [0]
    while(i < n):
        t = gcd(s,A[i])
        if t < s:
            Down.append(i)
        s = t
        i += 1
    return s,Down

if __name__ == "__main__":
    N = int(eval(input()))
    B = list(map(int,input().split()))
    max = 0
    d,Down = gcd_array(B)
    C = [i//d for i in B]
    c = C[0]
    K = 1
    for j in Down:
        A = [i for i in C]
        c = A.pop(j)
        l = gcd_array(A)[0]
        if K < l:
            K = l
    print((K * d))
# Original solution
import copy

n = int(eval(input()))
a = list(map(int, input().split()))
 
 
def gcd(x,y):
    while y:
        x,y = y, x % y
    return x
    
gcd_left = [0]
gcd_rigth = [0]
gcd_list = []

for i in range(n):
    s = gcd(gcd_left[i], a[i])
    gcd_left.append(s)
    
for i in range(n):
    t = gcd(gcd_rigth[i], a[-i-1])
    gcd_rigth.append(t)

for i in range(n):
    u = copy.copy(a)
    del u[i]
    v = gcd(gcd_left[i], gcd_rigth[n-1-i])
    gcd_list.append(v)

print((max(gcd_list)))


# 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
    
gcd_left = [0]
gcd_rigth = [0]
gcd_list = []

for i in range(n):
    s = gcd(gcd_left[i], a[i])
    gcd_left.append(s)
    
for i in range(n):
    t = gcd(gcd_rigth[i], a[-i-1])
    gcd_rigth.append(t)

for i in range(n):
    v = gcd(gcd_left[i], gcd_rigth[n-1-i])
    gcd_list.append(v)

print((max(gcd_list)))
# Original solution
from functools import reduce
def gcd(a,b):
    if a<b:
        a,b = b,a
    while b:
        a,b = b,a%b
    return a

N = int(eval(input()))
A = list(map(int,input().split()))
gcd_max = 0
for i in range(N):
    B = A.copy()
    B[i:i+1] = []
    gcd_max = max(gcd_max,reduce(gcd,B))
print(gcd_max)

# Optimized solution
def gcd(x,y):
    while y != 0:
        x,y = y,x%y
    return x
n = int(eval(input()))
a = list(map(int,input().split()))

L,R = [0],[0]
for i in range(1,n+1): #L[i]は左i個,R[i]は右i個
    L.append(gcd(L[-1],a[i-1]))
    R.append(gcd(R[-1],a[n-i]))
print((max(gcd(L[i],R[n-i-1]) for i in range(n))))
# Original solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def calc(a, b):
  if a == 1 or b == 1:
    return 1

  while a != 0 and b != 0:
    if a < b:
      b %= a
    else:
      a %= b

  return a if a != 0 else b


def main():
  input()
  a = list(map(int, input().split()))
  p = [a[0], a[1], calc(a[0], a[1])]

  for v in a[2:]:
    for j in range(len(p) - 1):
      p[j] = calc(p[j], v)

    p.append(calc(p[-1], v))

  print(max(p), flush=True)


if __name__ == '__main__':
  main()



# Optimized solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def cd(a, b):
  if a == 1 or b == 1:
    return 1

  while a != 0 and b != 0:
    if a < b:
      b %= a
    else:
      a %= b

  return a if a != 0 else b


def main():
  input()
  prevs = list(map(int, input().split()))
  posts = prevs[::-1]

  for i in range(1, len(prevs)):
    prevs[i] = cd(prevs[i - 1], prevs[i])
    posts[i] = cd(posts[i - 1], posts[i])

  posts = posts[::-1]

  gcd = max(prevs[-2], posts[1])

  for i in range(1, len(prevs) - 1):
    gcd = max(cd(prevs[i - 1], posts[i + 1]), gcd)

  print(gcd, flush=True)


if __name__ == '__main__':
  main()
# Original solution
# Segment tree (GCD)
from math import gcd


class SegmentTree:
    _f = None
    _data = None
    _offset = None
    _size = None

    def __init__(self, size, f):
        self._f = f
        self._size = size
        t = 1
        while t < size:
            t *= 2
        self._offset = t - 1
        self._data = [0] * (t * 2 - 1)

    def build(self, iterable):
        f = self._f
        data = self._data
        data[self._offset:self._offset + self._size] = iterable
        for i in range(self._offset - 1, -1, -1):
            data[i] = f(data[i * 2 + 1], data[i * 2 + 2])

    def query(self, start, stop):
        def iter_segments(data, l, r):
            while l < r:
                if l & 1 == 0:
                    yield data[l]
                if r & 1 == 0:
                    yield data[r - 1]
                l = l // 2
                r = (r - 1) // 2
        f = self._f
        it = iter_segments(self._data, start + self._offset,
                           stop + self._offset)
        result = next(it)
        for e in it:
            result = f(result, e)
        return result


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

st = SegmentTree(N, gcd)
st.build(A)

result = st.query(1, N)
for i in range(1, N - 1):
    result = max(result, gcd(st.query(0, i), st.query(i + 1, N)))
result = max(result, st.query(0, N - 1))
print(result)


# Optimized solution
from math import gcd


class SegmentTree:
    def __init__(self, size, op, e):
        self._op = op
        self._e = e
        self._size = size
        t = 1
        while t < size:
            t *= 2
        self._offset = t - 1
        self._data = [e] * (t * 2 - 1)

    def __getitem__(self, key):
        return self._data[self._offset + key]

    def __setitem__(self, key, value):
        op = self._op
        data = self._data
        i = self._offset + key
        data[i] = value
        while i >= 1:
            i = (i - 1) // 2
            data[i] = op(data[i * 2 + 1], data[i * 2 + 2])

    def build(self, iterable):
        op = self._op
        data = self._data
        data[self._offset:self._offset + self._size] = iterable
        for i in range(self._offset - 1, -1, -1):
            data[i] = op(data[i * 2 + 1], data[i * 2 + 2])

    def query(self, start, stop):
        def iter_segments(data, l, r):
            while l < r:
                if l & 1 == 0:
                    yield data[l]
                if r & 1 == 0:
                    yield data[r - 1]
                l = l // 2
                r = (r - 1) // 2
        op = self._op
        it = iter_segments(self._data, start + self._offset,
                           stop + self._offset)
        result = self._e
        for v in it:
            result = op(result, v)
        return result


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

st = SegmentTree(N, gcd, 0)
st.build(A)

result = st.query(1, N)
for i in range(1, N - 1):
    result = max(result, gcd(st.query(0, i), st.query(i + 1, N)))
result = max(result, st.query(0, N - 1))
print(result)
# Original solution
def gcd(a, b):
  while a:
    a, b = b % a, a
  return b

from functools import reduce

def g():
  n = int(eval(input()))
  vs = list(map(int, input().split()))
  
  mr = 0
  for i in range(len(vs)):
    r = reduce(gcd, vs[:i]+vs[i+1:])
    mr = max(mr, r)
  return mr
  
print((g()))


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


def g():
  from functools import reduce
  n = int(eval(input()))
  vs = list(map(int, input().split()))
  
  while True:
    n = len(vs)
    
    if n < 10:
      mrr = 0
      for i, v in enumerate(vs):
        rr = reduce(gcd, vs[:i]+vs[i+1:])
        mrr = max(rr, mrr)
      return mrr
    
    v1 = vs[:n//2]
    v2 = vs[n//2:]
    
    r1 = reduce(gcd, v1)
    r2 = reduce(gcd, v2)
    if r1 == r2:
      return r1
    if r1 > r2:
      vs = v2
    else:
      vs = v1
  
  
print((g()))
# Original solution
N = int(eval(input()))
numbers = list(map(int, input().split()))

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

gcd_forward = []
gcd_all = numbers[0]
for i in range(0, N - 1):
  gcd_all = gcd(gcd_all, numbers[i])
  gcd_forward.append(gcd_all)

gcd_backward = []
gcd_all = numbers[-1]
for i in range(N - 1, 0, -1):
  gcd_all = gcd(gcd_all, numbers[i])
  gcd_backward.insert(0, gcd_all)

gcd_forward.insert(0, gcd_backward[0])
gcd_backward.append(gcd_forward[-1])

gcd_max = 1
for i in range(N):
  gcd_max = max(gcd_max, gcd(gcd_forward[i], gcd_backward[i]))
  
print(gcd_max)


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

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

gcd_forward = [numbers[0]]
for i in range(1, N - 1):
  gcd_all = gcd(gcd_forward[-1], numbers[i])
  gcd_forward.append(gcd_all)

gcd_backward = [numbers[-1]]
for i in range(N - 2, 0, -1):
  gcd_all = gcd(gcd_backward[-1], numbers[i])
  gcd_backward.append(gcd_all)

gcd_max = 1
for i in range(N):
  gcd_temp = 1
  if (i == 0):
    gcd_temp = gcd_backward[-1]
  elif (i == N - 1):
    gcd_temp = gcd_forward[-1]
  else:
    gcd_temp = gcd(gcd_forward[i - 1], gcd_backward[N - 2 - i])
  gcd_max = max(gcd_max, gcd_temp)
  
print(gcd_max)
# Original solution
def gcd(a, b):
    while 1:
        a, b = b, a % b
        if b == 0:
            return a


from functools import reduce

n = int(eval(input()))
a_s = list(map(int, input().split()))
mx = 0
for i in range(n):
    b = a_s[:i] + a_s[i + 1:]
    g = reduce(gcd, b)
    if g > mx:
        mx = g
print(mx)


# Optimized solution
import sys
sys.setrecursionlimit(10**6)

def Lgcd(i):
    if i == 0:
        return 0
    if i == 1:
        return a_s[0]
    if i in Lmemo:
        return Lmemo[i]
    re = gcd(Lgcd(i - 1), a_s[i - 1])
    Lmemo[i] = re
    return re


def Rgcd(i):
    if i == n - 1:
        return 0
    if i == n - 2:
        return a_s[-1]
    if i in Rmemo:
        return Rmemo[i]
    re = gcd(Rgcd(i + 1), a_s[i + 1])
    Rmemo[i] = re
    return re


def gcd(a, b):
    if a * b == 0:
        return a + b
    while 1:
        a, b = b, a % b
        if b == 0:
            return a


Lmemo = {}
Rmemo = {}
n = int(eval(input()))
a_s = list(map(int, input().split()))
mx = 0
for i in range(n):
    g = gcd(Lgcd(i),Rgcd(i))
    if g > mx:
        mx = g
print(mx)
# Original solution
import sys
sys.setrecursionlimit(10**6)

def Lgcd(i):
    if i == 0:
        return 0
    if i == 1:
        return a_s[0]
    if i in Lmemo:
        return Lmemo[i]
    re = gcd(Lgcd(i - 1), a_s[i - 1])
    Lmemo[i] = re
    return re


def Rgcd(i):
    if i == n - 1:
        return 0
    if i == n - 2:
        return a_s[-1]
    if i in Rmemo:
        return Rmemo[i]
    re = gcd(Rgcd(i + 1), a_s[i + 1])
    Rmemo[i] = re
    return re


def gcd(a, b):
    if a * b == 0:
        return a + b
    while 1:
        a, b = b, a % b
        if b == 0:
            return a


Lmemo = {}
Rmemo = {}
n = int(eval(input()))
a_s = list(map(int, input().split()))
mx = 0
for i in range(n):
    g = gcd(Lgcd(i),Rgcd(i))
    if g > mx:
        mx = g
print(mx)


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def gcd(a,b):
    while b>0:a,b=b,a%b
    return a

def main():
    n=int(input())
    aa=LI()
    gl=[0]*n
    gr=[0]*n
    g=aa[0]
    for i,a in enumerate(aa):
        g=gcd(g,a)
        gl[i]=g
    g=aa[-1]
    for i,a in enumerate(aa[::-1]):
        g=gcd(g,a)
        gr[n-1-i]=g
    ans=max(gl[n-2],gr[1])
    for i in range(1,n-1):
        g=gcd(gl[i-1],gr[i+1])
        if g>ans:ans=g
    print(ans)

main()
# Original solution
def gcd(a,b):
    c = a//b
    d = a%b
    if d==0:
        return b
    else:
        return gcd(b,d)


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



max_saidaikouyakusu = 0
for i in range(n):#nums[i]がない時の最大公約数を求める
    saidaikouyakusu = None
    for j in range(n):
        if j== i:continue
        else:
            if saidaikouyakusu==None:
                saidaikouyakusu = nums[j]
            else:
                saidaikouyakusu = gcd(saidaikouyakusu,nums[j])
    if max_saidaikouyakusu < saidaikouyakusu:
        max_saidaikouyakusu=saidaikouyakusu


print(max_saidaikouyakusu)


# Optimized solution
def gcd(a,b):
    a,b=max(a,b),min(a,b)
    if b==0:
        return a
    c = a//b
    d = a%b
    if d==0:
        return b
    else:
        return gcd(b,d)


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


l = [0 for _ in range(n)]
l[0]=0
for i in range(1,n):#nums[i]左側の最大公約数を求める
    l[i]=gcd(l[i-1],nums[i-1])

r=[0 for _ in range(n)]
r[-1]=0
for i in reversed(list(range(0,n-1))):#nums[i]の右側の最大公約数を求める
    r[i]=(gcd(nums[i+1],r[i+1]))

ans=0
for i in range(n):
    saidaikouyakusu_except_for_ni=gcd(l[i],r[i])
    if ans < saidaikouyakusu_except_for_ni:
        ans = saidaikouyakusu_except_for_ni
    else:pass

print(ans)