def gcd(a,b):

  if a*b == 0:

    return max(a,b)

  if a<b:

    a,b = b,a

  return gcd(b,a%b)

n = int(eval(input()))

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

length = 2**(n.bit_length())

calc = gcd

unit = 0

Seg = [unit for i in range(length*2-1)]

def init():

  for i in range(n):

    Seg[i+length-1] = ls[i]

  for i in range(length-2,-1,-1):

    Seg[i] = calc(Seg[2*i+1],Seg[2*i+2])

def update(i,x):

  i += length-1

  Seg[i] = x

  while i>0:

    i = (i-1)//2

    Seg[i] = calc(Seg[2*i+1],Seg[2*i+2])

def query(a,b,k,l,r):

  if r<=a or b<=l:

    return unit

  if a<=l and r<=b:

    return Seg[k]

  else:

    vl = query(a,b,2*k+1,l,(l+r)//2)

    vr = query(a,b,2*k+2,(l+r)//2,r)

    return calc(vl,vr)



init()

ans = []

for i in range(n):

  ans.append(gcd(query(0,i,0,0,length),query(i+1,n,0,0,length)))

print((max(ans)))
from fractions import gcd

ide = 0

def func(a,b):

  return gcd(a,b)

class SegmentTree:

  def __init__(self,ls):

    n = len(ls)

    self.tree = [ide for i in range(n)]+ls

    for i in range(1,n)[::-1]:

      self.tree[i] = func(self.tree[i<<1|0],self.tree[i<<1|1])

  def get(self,l,r):

    ret = ide

    l += n

    r += n

    while l < r:

      if l&1:

        ret = func(ret,self.tree[l])

        l += 1

      if r&1:

        ret = func(ret,self.tree[r-1])

      l >>= 1

      r >>= 1

    return ret

  def update(self,i,x):

    i += n

    self.tree[i] = x

    while i > 1:

      i >>= 1

      self.tree[i] = func(self.tree[i<<1|0],self.tree[i<<1|1])



import sys

input = sys.stdin.readline

n = int(eval(input()))

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

sol = SegmentTree(a)

ans = 0

for i in range(n):

  t = a[i]

  sol.update(i,0)

  ans = max(ans,sol.get(0,n))

  sol.update(i,t)

print(ans)

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


n = int(eval(input()))
ls = list(map(int, input().split()))
length = 2 ** (n.bit_length())
calc = gcd
unit = 0
Seg = [unit for i in range(length * 2 - 1)]


def init():
    for i in range(n):
        Seg[i + length - 1] = ls[i]
    for i in range(length - 2, -1, -1):
        Seg[i] = calc(Seg[2 * i + 1], Seg[2 * i + 2])


def update(i, x):
    i += length - 1
    Seg[i] = x
    while i > 0:
        i = (i - 1) // 2
        Seg[i] = calc(Seg[2 * i + 1], Seg[2 * i + 2])


def query(a, b, k, l, r):
    if r <= a or b <= l:
        return unit
    if a <= l and r <= b:
        return Seg[k]
    else:
        vl = query(a, b, 2 * k + 1, l, (l + r) // 2)
        vr = query(a, b, 2 * k + 2, (l + r) // 2, r)
        return calc(vl, vr)


init()
ans = []
for i in range(n):
    ans.append(gcd(query(0, i, 0, 0, length), query(i + 1, n, 0, 0, length)))
print((max(ans)))

from fractions import gcd

ide = 0


def func(a, b):
    return gcd(a, b)


class SegmentTree:
    def __init__(self, ls):
        n = len(ls)
        self.tree = [ide for i in range(n)] + ls
        for i in range(1, n)[::-1]:
            self.tree[i] = func(self.tree[i << 1 | 0], self.tree[i << 1 | 1])

    def get(self, l, r):
        ret = ide
        l += n
        r += n
        while l < r:
            if l & 1:
                ret = func(ret, self.tree[l])
                l += 1
            if r & 1:
                ret = func(ret, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return ret

    def update(self, i, x):
        i += n
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = func(self.tree[i << 1 | 0], self.tree[i << 1 | 1])


import sys

input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
sol = SegmentTree(a)
ans = 0
for i in range(n):
    t = a[i]
    sol.update(i, 0)
    ans = max(ans, sol.get(0, n))
    sol.update(i, t)
print(ans)

-def gcd(a, b): -    if a * b == 0: -        return max(a, b) -    if a < b: -        a, b = b, a -    return gcd(b, a % b) +from fractions import gcd + +ide = 0 -n = int(eval(input())) -ls = list(map(int, input().split())) -length = 2 ** (n.bit_length()) -calc = gcd -unit = 0 -Seg = [unit for i in range(length * 2 - 1)] +def func(a, b): +    return gcd(a, b) -def init(): -    for i in range(n): -        Seg[i + length - 1] = ls[i] -    for i in range(length - 2, -1, -1): -        Seg[i] = calc(Seg[2 * i + 1], Seg[2 * i + 2]) +class SegmentTree: +    def __init__(self, ls): +        n = len(ls) +        self.tree = [ide for i in range(n)] + ls +        for i in range(1, n)[::-1]: +            self.tree[i] = func(self.tree[i << 1 | 0], self.tree[i << 1 | 1]) + +    def get(self, l, r): +        ret = ide +        l += n +        r += n +        while l < r: +            if l & 1: +                ret = func(ret, self.tree[l]) +                l += 1 +            if r & 1: +                ret = func(ret, self.tree[r - 1]) +            l >>= 1 +            r >>= 1 +        return ret + +    def update(self, i, x): +        i += n +        self.tree[i] = x +        while i > 1: +            i >>= 1 +            self.tree[i] = func(self.tree[i << 1 | 0], self.tree[i << 1 | 1]) -def update(i, x): -    i += length - 1 -    Seg[i] = x -    while i > 0: -        i = (i - 1) // 2 -        Seg[i] = calc(Seg[2 * i + 1], Seg[2 * i + 2]) +import sys - -def query(a, b, k, l, r): -    if r <= a or b <= l: -        return unit -    if a <= l and r <= b: -        return Seg[k] -    else: -        vl = query(a, b, 2 * k + 1, l, (l + r) // 2) -        vr = query(a, b, 2 * k + 2, (l + r) // 2, r) -        return calc(vl, vr) - - -init() -ans = [] +input = sys.stdin.readline +n = int(eval(input())) +a = list(map(int, input().split())) +sol = SegmentTree(a) +ans = 0 -    ans.append(gcd(query(0, i, 0, 0, length), query(i + 1, n, 0, 0, length))) -print((max(ans))) +    t = a[i] +    sol.update(i, 0) +    ans = max(ans, sol.get(0, n)) +    sol.update(i, t) +print(ans)