from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf

from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement

from collections import deque,defaultdict,Counter

from bisect import bisect_left,bisect_right

from operator import itemgetter

from heapq import heapify,heappop,heappush

from queue import Queue,LifoQueue,PriorityQueue

from copy import deepcopy

from time import time

from functools import reduce

import string

import sys

sys.setrecursionlimit(10 ** 7)

def input() : return sys.stdin.readline().strip()

def INT()   : return int(eval(input()))

def MAP()   : return list(map(int,input().split()))

def MAP1()  : return [int(x)-1 for x in input().split()]

def LIST()  : return list(MAP())

def LIST1() : return list(MAP1())



#####segfunc#####

def segfunc(x, y):

    return gcd(x, y)

#################



#####ide_ele#####

ide_ele = 0

#################



class SegTree:

    """

    init(init_val, ide_ele): 配列init_valで初期化 O(N)

    update(k, x): k番目の値をxに更新 O(logN)

    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)

    """

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

        """

        init_val: 配列の初期値

        segfunc: 区間にしたい操作

        ide_ele: 単位元

        n: 要素数

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

        tree: セグメント木(1-index)

        """

        n = len(init_val)

        self.segfunc = segfunc

        self.ide_ele = ide_ele

        self.num = 1 << (n - 1).bit_length()

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

        # 配列の値を葉にセット

        for i in range(n):

            self.tree[self.num + i] = init_val[i]

        # 構築していく

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

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



    def update(self, k, x):

        """

        k番目の値をxに更新

        k: index(0-index)

        x: update value

        """

        k += self.num

        self.tree[k] = x

        while k > 1:

            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])

            k >>= 1



    def query(self, l, r):

        """

        [l, r)のsegfuncしたものを得る

        l: index(0-index)

        r: index(0-index)

        """

        res = self.ide_ele



        l += self.num

        r += self.num

        while l < r:

            if l & 1:

                res = self.segfunc(res, self.tree[l])

                l += 1

            if r & 1:

                res = self.segfunc(res, self.tree[r - 1])

            l >>= 1

            r >>= 1

        return res



def solve():

    N = INT()

    a = LIST()

    seg = SegTree(a, segfunc, ide_ele)



    ans = 1

    for i in range(N):

        seg.update(i, 0)

        ans = max(ans, seg.query(0, N))

        seg.update(i, a[i])

    print(ans)



if __name__ == '__main__':

    solve()
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf

from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement

from collections import deque,defaultdict,Counter

from bisect import bisect_left,bisect_right

from operator import itemgetter

from heapq import heapify,heappop,heappush

from queue import Queue,LifoQueue,PriorityQueue

from copy import deepcopy

from time import time

from functools import reduce

import string

import sys

sys.setrecursionlimit(10 ** 7)

def input() : return sys.stdin.readline().strip()

def INT()   : return int(eval(input()))

def MAP()   : return list(map(int,input().split()))

def MAP1()  : return [int(x)-1 for x in input().split()]

def LIST()  : return list(MAP())

def LIST1() : return list(MAP1())



def solve():

    N = INT()

    a = LIST()

    l = [0]*N

    r = [0]*N

    l[0] = a[0]

    r[N-1] = a[N-1]



    for i in range(1, N):

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

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

        r[i] = gcd(r[i+1], a[i])



    ans = max(r[1], l[N-2])

    for i in range(1, N-1):

        ans = max(ans, gcd(l[i-1], r[i+1]))

    print(ans)

    

if __name__ == '__main__':

    solve()
from math import (
    ceil,
    floor,
    factorial,
    gcd,
    sqrt,
    log2,
    cos,
    sin,
    tan,
    acos,
    asin,
    atan,
    degrees,
    radians,
    pi,
    inf,
)
from itertools import (
    accumulate,
    groupby,
    permutations,
    combinations,
    product,
    combinations_with_replacement,
)
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import Queue, LifoQueue, PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys

sys.setrecursionlimit(10**7)


def input():
    return sys.stdin.readline().strip()


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def MAP1():
    return [int(x) - 1 for x in input().split()]


def LIST():
    return list(MAP())


def LIST1():
    return list(MAP1())


#####segfunc#####
def segfunc(x, y):
    return gcd(x, y)


#################
#####ide_ele#####
ide_ele = 0
#################
class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """

    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


def solve():
    N = INT()
    a = LIST()
    seg = SegTree(a, segfunc, ide_ele)
    ans = 1
    for i in range(N):
        seg.update(i, 0)
        ans = max(ans, seg.query(0, N))
        seg.update(i, a[i])
    print(ans)


if __name__ == "__main__":
    solve()

from math import (
    ceil,
    floor,
    factorial,
    gcd,
    sqrt,
    log2,
    cos,
    sin,
    tan,
    acos,
    asin,
    atan,
    degrees,
    radians,
    pi,
    inf,
)
from itertools import (
    accumulate,
    groupby,
    permutations,
    combinations,
    product,
    combinations_with_replacement,
)
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import Queue, LifoQueue, PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys

sys.setrecursionlimit(10**7)


def input():
    return sys.stdin.readline().strip()


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def MAP1():
    return [int(x) - 1 for x in input().split()]


def LIST():
    return list(MAP())


def LIST1():
    return list(MAP1())


def solve():
    N = INT()
    a = LIST()
    l = [0] * N
    r = [0] * N
    l[0] = a[0]
    r[N - 1] = a[N - 1]
    for i in range(1, N):
        l[i] = gcd(l[i - 1], a[i])
    for i in range(N - 2, -1, -1):
        r[i] = gcd(r[i + 1], a[i])
    ans = max(r[1], l[N - 2])
    for i in range(1, N - 1):
        ans = max(ans, gcd(l[i - 1], r[i + 1]))
    print(ans)


if __name__ == "__main__":
    solve()

-#####segfunc##### -def segfunc(x, y): -    return gcd(x, y) - - -################# -#####ide_ele##### -ide_ele = 0 -################# -class SegTree: -    """ -    init(init_val, ide_ele): 配列init_valで初期化 O(N) -    update(k, x): k番目の値をxに更新 O(logN) -    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN) -    """ - -    def __init__(self, init_val, segfunc, ide_ele): -        """ -        init_val: 配列の初期値 -        segfunc: 区間にしたい操作 -        ide_ele: 単位元 -        n: 要素数 -        num: n以上の最小の2のべき乗 -        tree: セグメント木(1-index) -        """ -        n = len(init_val) -        self.segfunc = segfunc -        self.ide_ele = ide_ele -        self.num = 1 << (n - 1).bit_length() -        self.tree = [ide_ele] * 2 * self.num -        # 配列の値を葉にセット -        for i in range(n): -            self.tree[self.num + i] = init_val[i] -        # 構築していく -        for i in range(self.num - 1, 0, -1): -            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) - -    def update(self, k, x): -        """ -        k番目の値をxに更新 -        k: index(0-index) -        x: update value -        """ -        k += self.num -        self.tree[k] = x -        while k > 1: -            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1]) -            k >>= 1 - -    def query(self, l, r): -        """ -        [l, r)のsegfuncしたものを得る -        l: index(0-index) -        r: index(0-index) -        """ -        res = self.ide_ele -        l += self.num -        r += self.num -        while l < r: -            if l & 1: -                res = self.segfunc(res, self.tree[l]) -                l += 1 -            if r & 1: -                res = self.segfunc(res, self.tree[r - 1]) -            l >>= 1 -            r >>= 1 -        return res - - -    seg = SegTree(a, segfunc, ide_ele) -    ans = 1 -    for i in range(N): -        seg.update(i, 0) -        ans = max(ans, seg.query(0, N)) -        seg.update(i, a[i]) +    l = [0] * N +    r = [0] * N +    l[0] = a[0] +    r[N - 1] = a[N - 1] +    for i in range(1, N): +        l[i] = gcd(l[i - 1], a[i]) +    for i in range(N - 2, -1, -1): +        r[i] = gcd(r[i + 1], a[i]) +    ans = max(r[1], l[N - 2]) +    for i in range(1, N - 1): +        ans = max(ans, gcd(l[i - 1], r[i + 1]))