import sys,collections as cl,bisect as bs

sys.setrecursionlimit(100000)

input = sys.stdin.readline

mod = 10**9+7

Max = sys.maxsize

import fractions

from functools import reduce

def gcd(*numbers):

    return reduce(fractions.gcd, numbers)



def gcd_list(numbers):

    return reduce(fractions.gcd, numbers)

def lcm_base(x, y):

    return (x * y) // fractions.gcd(x, y)



def lcm(*numbers):

    return reduce(lcm_base, numbers, 1)



def lcm_list(numbers):

    return reduce(lcm_base, numbers, 1)

def l(): #intのlist

    return list(map(int,input().split()))

def m(): #複数文字

    return list(map(int,input().split()))

def onem(): #Nとかの取得

    return int(eval(input()))

def s(x): #圧縮

    a = []

    aa = x[0]

    su = 1

    for i in range(len(x)-1):

        if aa != x[i+1]:

            a.append([aa,su])

            aa = x[i+1]

            su = 1

        else:

            su += 1

    a.append([aa,su])

    return a

def jo(x): #listをスペースごとに分ける

    return " ".join(map(str,x))

def max2(x): #他のときもどうように作成可能

    return max(list(map(max,x)))

def In(x,a): #aがリスト(sorted)

    k = bs.bisect_left(a,x)

    if k != len(a) and a[k] ==  x:

        return True

    else:

        return False

"""

def nibu(x,n,r):

    ll = 0

    rr = r

    while True:

        mid = (ll+rr)//2



    if rr == mid:

        return ll

    if (ここに評価入れる):

        rr = mid

    else:

        ll = mid+1

"""

class SegmentTree:

    def segfunc(self,x,y):

        return gcd(x,y)



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

        self.n = n

        self.ide_ele = ide_ele

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

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

        for i in range(n):

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

        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:

            lk = (k-1)//2

            self.seg[k] = self.segfunc(self.seg[2*k+1],self.seg[2*k+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 //= 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



n = onem()



a = l()





ans = 0

p = SegmentTree(n,a,0)

for i in range(n):

    ans = max(ans,gcd(p.query(0,i),p.query(i+1,n)))

print(ans)



import sys,collections as cl,bisect as bs

sys.setrecursionlimit(100000)

input = sys.stdin.readline

mod = 10**9+7

Max = sys.maxsize

def l(): #intのlist

    return list(map(int,input().split()))

def m(): #複数文字

    return list(map(int,input().split()))

def onem(): #Nとかの取得

    return int(eval(input()))

def s(x): #圧縮

    a = []

    if len(x) == 0:

        return []

    aa = x[0]

    su = 1

    for i in range(len(x)-1):

        if aa != x[i+1]:

            a.append([aa,su])

            aa = x[i+1]

            su = 1

        else:

            su += 1

    a.append([aa,su])

    return a

def jo(x): #listをスペースごとに分ける

    return " ".join(map(str,x))

def max2(x): #他のときもどうように作成可能

    return max(list(map(max,x)))

def In(x,a): #aがリスト(sorted)

    k = bs.bisect_left(a,x)

    if k != len(a) and a[k] ==  x:

        return True

    else:

        return False



def pow_k(x, n):

    ans = 1

    while n:

        if n % 2:

            ans *= x

        x *= x

        n >>= 1

    return ans



"""

def nibu(x,n,r):

    ll = 0

    rr = r

    while True:

        mid = (ll+rr)//2



    if rr == mid:

        return ll

    if (ここに評価入れる):

        rr = mid

    else:

        ll = mid+1

"""

import math

from functools import reduce

def gcd(*numbers):

    return reduce(math.gcd, numbers)



def gcd_list(numbers):

    return reduce(math.gcd, numbers)

def lcm_base(x, y):

    return (x * y) // math.gcd(x, y)



def lcm(*numbers):

    return reduce(lcm_base, numbers, 1)



def lcm_list(numbers):

    return reduce(lcm_base, numbers, 1)





n = onem()



a = l()



R = [1 for i in range(n)]

L = [1 for i in range(n)]



for i in range(n):

    ii = -(i+1) 

    if i == 0:

        R[ii] = a[ii]

        L[i] = a[i]

    else:

        R[ii] = gcd(R[ii+1],a[ii])

        L[i] = gcd(L[i-1],a[i])

ma = 1



for i in range(n):

    if i == 0:

        ma = max(ma,R[1])

    elif i == n-1:

        ma = max(ma,L[-2])

    else:

        ma = max(ma,gcd(L[i-1],R[i+1]))

print(ma)







import sys, collections as cl, bisect as bs

sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9 + 7
Max = sys.maxsize
import fractions
from functools import reduce


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


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


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def l():  # intのlist
    return list(map(int, input().split()))


def m():  # 複数文字
    return list(map(int, input().split()))


def onem():  # Nとかの取得
    return int(eval(input()))


def s(x):  # 圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x) - 1):
        if aa != x[i + 1]:
            a.append([aa, su])
            aa = x[i + 1]
            su = 1
        else:
            su += 1
    a.append([aa, su])
    return a


def jo(x):  # listをスペースごとに分ける
    return " ".join(map(str, x))


def max2(x):  # 他のときもどうように作成可能
    return max(list(map(max, x)))


def In(x, a):  # aがリスト(sorted)
    k = bs.bisect_left(a, x)
    if k != len(a) and a[k] == x:
        return True
    else:
        return False


"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2
    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


class SegmentTree:
    def segfunc(self, x, y):
        return gcd(x, y)

    def __init__(self, n, init, ide_ele):
        self.n = n
        self.ide_ele = ide_ele
        self.num = 2 ** (n - 1).bit_length()
        self.seg = [ide_ele] * 2 * self.num
        for i in range(n):
            self.seg[i + self.num - 1] = init[i]
        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:
            lk = (k - 1) // 2
            self.seg[k] = self.segfunc(self.seg[2 * k + 1], self.seg[2 * k + 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 //= 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


n = onem()
a = l()
ans = 0
p = SegmentTree(n, a, 0)
for i in range(n):
    ans = max(ans, gcd(p.query(0, i), p.query(i + 1, n)))
print(ans)

import sys, collections as cl, bisect as bs

sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9 + 7
Max = sys.maxsize


def l():  # intのlist
    return list(map(int, input().split()))


def m():  # 複数文字
    return list(map(int, input().split()))


def onem():  # Nとかの取得
    return int(eval(input()))


def s(x):  # 圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x) - 1):
        if aa != x[i + 1]:
            a.append([aa, su])
            aa = x[i + 1]
            su = 1
        else:
            su += 1
    a.append([aa, su])
    return a


def jo(x):  # listをスペースごとに分ける
    return " ".join(map(str, x))


def max2(x):  # 他のときもどうように作成可能
    return max(list(map(max, x)))


def In(x, a):  # aがリスト(sorted)
    k = bs.bisect_left(a, x)
    if k != len(a) and a[k] == x:
        return True
    else:
        return False


def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans


"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2
    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


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


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n = onem()
a = l()
R = [1 for i in range(n)]
L = [1 for i in range(n)]
for i in range(n):
    ii = -(i + 1)
    if i == 0:
        R[ii] = a[ii]
        L[i] = a[i]
    else:
        R[ii] = gcd(R[ii + 1], a[ii])
        L[i] = gcd(L[i - 1], a[i])
ma = 1
for i in range(n):
    if i == 0:
        ma = max(ma, R[1])
    elif i == n - 1:
        ma = max(ma, L[-2])
    else:
        ma = max(ma, gcd(L[i - 1], R[i + 1]))
print(ma)

-import fractions -from functools import reduce - - -def gcd(*numbers): -    return reduce(fractions.gcd, numbers) - - -def gcd_list(numbers): -    return reduce(fractions.gcd, numbers) - - -def lcm_base(x, y): -    return (x * y) // fractions.gcd(x, y) - - -def lcm(*numbers): -    return reduce(lcm_base, numbers, 1) - - -def lcm_list(numbers): -    return reduce(lcm_base, numbers, 1) +    if len(x) == 0: +        return [] +def pow_k(x, n): +    ans = 1 +    while n: +        if n % 2: +            ans *= x +        x *= x +        n >>= 1 +    return ans + + +import math +from functools import reduce -class SegmentTree: -    def segfunc(self, x, y): -        return gcd(x, y) +def gcd(*numbers): +    return reduce(math.gcd, numbers) -    def __init__(self, n, init, ide_ele): -        self.n = n -        self.ide_ele = ide_ele -        self.num = 2 ** (n - 1).bit_length() -        self.seg = [ide_ele] * 2 * self.num -        for i in range(n): -            self.seg[i + self.num - 1] = init[i] -        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: -            lk = (k - 1) // 2 -            self.seg[k] = self.segfunc(self.seg[2 * k + 1], self.seg[2 * k + 2]) +def gcd_list(numbers): +    return reduce(math.gcd, numbers) -    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 //= 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 + +def lcm_base(x, y): +    return (x * y) // math.gcd(x, y) + + +def lcm(*numbers): +    return reduce(lcm_base, numbers, 1) + + +def lcm_list(numbers): +    return reduce(lcm_base, numbers, 1) -ans = 0 -p = SegmentTree(n, a, 0) +R = [1 for i in range(n)] +L = [1 for i in range(n)] -    ans = max(ans, gcd(p.query(0, i), p.query(i + 1, n))) -print(ans) +    ii = -(i + 1) +    if i == 0: +        R[ii] = a[ii] +        L[i] = a[i] +    else: +        R[ii] = gcd(R[ii + 1], a[ii]) +        L[i] = gcd(L[i - 1], a[i]) +ma = 1 +for i in range(n): +    if i == 0: +        ma = max(ma, R[1]) +    elif i == n - 1: +        ma = max(ma, L[-2]) +    else: +        ma = max(ma, gcd(L[i - 1], R[i + 1])) +print(ma)