import sys

from fractions import gcd

input = sys.stdin.readline

N = int(eval(input()))

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

class SegTree:

  def segfunc(self, x, y):

    return gcd(x, y) #ここ判定関数（ただし結合則があるもの）

  def __init__(self, n, ide_ele, init_val):

    #####単位元######

    self.ide_ele = ide_ele

    #num:n以上の最小の2のべき乗

    self.num = 2 ** (n - 1).bit_length()

    self.seg = [self.ide_ele] * 2 * self.num

    #set_val

    for i in range(n):

      self.seg[i + self.num - 1] = init_val[i]    

    #built

    for i in range(self.num - 2, -1, -1) :

      self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) 

  def update(self, k, x):

    k += self.num - 1

    self.seg[k] = x

    while k + 1:

      k = (k - 1) // 2

      self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) 

  def query(self, p, q):

    if q <= p:

      return self.ide_ele

    p += self.num - 1

    q += self.num - 2

    res = self.ide_ele

    while q - p > 1:

      if p & 1 == 0:

        res = self.segfunc(res, self.seg[p])

      if q & 1 == 1:

        res = self.segfunc(res, self.seg[q])

        q -= 1

      p = p // 2

      q = (q - 1) // 2

    if p == q:

      res = self.segfunc(res, self.seg[p])

    else:

      res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])

    return res

seg = SegTree(N, 0, a)

res = 0

for i in range(N):

  res = max(res, gcd(seg.query(0, i), seg.query(i + 1, N)))

  #print(seg.query(0, i), seg.query(i + 1, N))

print(res)
import sys

from fractions import gcd

input = sys.stdin.readline

N = int(eval(input()))

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

l = [0] * (N + 1)

r = [0] * (N + 1)

for i in range(N): l[i + 1] = gcd(l[i], a[i])

a.reverse()

for i in range(N): r[i + 1] = gcd(r[i], a[i])

res = 0

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

print(res)

import sys
from fractions import gcd

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


class SegTree:
    def segfunc(self, x, y):
        return gcd(x, y)  # ここ判定関数（ただし結合則があるもの）

    def __init__(self, n, ide_ele, init_val):
        #####単位元######
        self.ide_ele = ide_ele
        # num:n以上の最小の2のべき乗
        self.num = 2 ** (n - 1).bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        # set_val
        for i in range(n):
            self.seg[i + self.num - 1] = init_val[i]
        # built
        for i in range(self.num - 2, -1, -1):
            self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2])

    def update(self, k, x):
        k += self.num - 1
        self.seg[k] = x
        while k + 1:
            k = (k - 1) // 2
            self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2])

    def query(self, p, q):
        if q <= p:
            return self.ide_ele
        p += self.num - 1
        q += self.num - 2
        res = self.ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q & 1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res


seg = SegTree(N, 0, a)
res = 0
for i in range(N):
    res = max(res, gcd(seg.query(0, i), seg.query(i + 1, N)))
    # print(seg.query(0, i), seg.query(i + 1, N))
print(res)

import sys
from fractions import gcd

input = sys.stdin.readline
N = int(eval(input()))
a = list(map(int, input().split()))
l = [0] * (N + 1)
r = [0] * (N + 1)
for i in range(N):
    l[i + 1] = gcd(l[i], a[i])
a.reverse()
for i in range(N):
    r[i + 1] = gcd(r[i], a[i])
res = 0
for i in range(N + 1):
    res = max(res, gcd(l[i], r[N - i - 1]))
print(res)

- - -class SegTree: -    def segfunc(self, x, y): -        return gcd(x, y)  # ここ判定関数（ただし結合則があるもの） - -    def __init__(self, n, ide_ele, init_val): -        #####単位元###### -        self.ide_ele = ide_ele -        # num:n以上の最小の2のべき乗 -        self.num = 2 ** (n - 1).bit_length() -        self.seg = [self.ide_ele] * 2 * self.num -        # set_val -        for i in range(n): -            self.seg[i + self.num - 1] = init_val[i] -        # built -        for i in range(self.num - 2, -1, -1): -            self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) - -    def update(self, k, x): -        k += self.num - 1 -        self.seg[k] = x -        while k + 1: -            k = (k - 1) // 2 -            self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) - -    def query(self, p, q): -        if q <= p: -            return self.ide_ele -        p += self.num - 1 -        q += self.num - 2 -        res = self.ide_ele -        while q - p > 1: -            if p & 1 == 0: -                res = self.segfunc(res, self.seg[p]) -            if q & 1 == 1: -                res = self.segfunc(res, self.seg[q]) -                q -= 1 -            p = p // 2 -            q = (q - 1) // 2 -        if p == q: -            res = self.segfunc(res, self.seg[p]) -        else: -            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) -        return res - - -seg = SegTree(N, 0, a) +l = [0] * (N + 1) +r = [0] * (N + 1) +for i in range(N): +    l[i + 1] = gcd(l[i], a[i]) +a.reverse() +for i in range(N): +    r[i + 1] = gcd(r[i], a[i]) -for i in range(N): -    res = max(res, gcd(seg.query(0, i), seg.query(i + 1, N))) -    # print(seg.query(0, i), seg.query(i + 1, N)) +for i in range(N + 1): +    res = max(res, gcd(l[i], r[N - i - 1]))