class SegTree():

    def __init__(self,data,unit,f):

        self.size=n=len(data)

        self.data=[unit for _ in range(n)]+data

        for i in range(n-1,0,-1):self.data[i]=f(self.data[i+i],self.data[i-~i])

        self.unit=unit

        self.f=f

    def update(self,i,x):

        c,f=self.data,self.f

        i+=self.size

        c[i]=x

        while i>1:

            i>>=1

            c[i]=f(c[i+i],c[i-~i])

    def add(self,i,x):

        c,f=self.data,self.f

        i+=self.size

        c[i]=f(c[i],x)

        while i>1:

            i>>=1

            c[i]=f(c[i+i],c[i-~i])

    def query(self,l,r):

        c,f=self.data,self.f

        x,y=self.unit,self.unit

        l+=self.size

        r+=self.size

        while l<r:

            if l&1:

                x=f(x,c[l])

                l+=1

            if r&1:

                r-=1

                y=f(c[r],y)

            l>>=1

            r>>=1

        return f(x,y)

def main():

    from fractions import gcd

    n,*a=list(map(int,open(0).read().split()))

    f=SegTree(a,0,gcd).query

    m=max(f(1,n),f(0,n-1))

    for i in range(n-2):

        m=max(m,gcd(f(0,i+1),f(i+2,n)))

    print(m)

main()
class DisjointSparseTable():

    def __init__(self,data,f):

        from math import ceil,log#2

        self.n=n=len(data)

        m=ceil(log(n,2)) # ceil(log2(n))

        self.f=f

        self.h=[0,0]

        for i in range(2,2**m):self.h.append(self.h[i//2]+1)

        self.data=[data]

        for i in range(1,m):

            d=[0]*n

            w=2**i

            for j in range(0,n,w*2):

                c=min(j+w,n)

                d[c-1]=data[c-1]

                for k in range(c-2,j-1,-1):d[k]=f(data[k],d[k+1])

                if c<n:

                    d[c]=data[c]

                    for k in range(c+1,min(j+w*2,n)):d[k]=f(data[k],d[k-1])

            self.data.append(d)

    def get(self,l,r): # [l,r)

        r-=1

        if l==r:return self.data[0][l]

        d=self.data[self.h[l^r]]

        return self.f(d[l],d[r])

def main():

    from fractions import gcd

    n,*a=list(map(int,open(0).read().split()))

    f=DisjointSparseTable(a,gcd).get

    m=max(f(1,n),f(0,n-1))

    for i in range(n-2):

        m=max(m,gcd(f(0,i+1),f(i+2,n)))

    print(m)

main()
class SegTree:
    def __init__(self, data, unit, f):
        self.size = n = len(data)
        self.data = [unit for _ in range(n)] + data
        for i in range(n - 1, 0, -1):
            self.data[i] = f(self.data[i + i], self.data[i - ~i])
        self.unit = unit
        self.f = f

    def update(self, i, x):
        c, f = self.data, self.f
        i += self.size
        c[i] = x
        while i > 1:
            i >>= 1
            c[i] = f(c[i + i], c[i - ~i])

    def add(self, i, x):
        c, f = self.data, self.f
        i += self.size
        c[i] = f(c[i], x)
        while i > 1:
            i >>= 1
            c[i] = f(c[i + i], c[i - ~i])

    def query(self, l, r):
        c, f = self.data, self.f
        x, y = self.unit, self.unit
        l += self.size
        r += self.size
        while l < r:
            if l & 1:
                x = f(x, c[l])
                l += 1
            if r & 1:
                r -= 1
                y = f(c[r], y)
            l >>= 1
            r >>= 1
        return f(x, y)


def main():
    from fractions import gcd

    n, *a = list(map(int, open(0).read().split()))
    f = SegTree(a, 0, gcd).query
    m = max(f(1, n), f(0, n - 1))
    for i in range(n - 2):
        m = max(m, gcd(f(0, i + 1), f(i + 2, n)))
    print(m)


main()

class DisjointSparseTable:
    def __init__(self, data, f):
        from math import ceil, log  # 2

        self.n = n = len(data)
        m = ceil(log(n, 2))  # ceil(log2(n))
        self.f = f
        self.h = [0, 0]
        for i in range(2, 2**m):
            self.h.append(self.h[i // 2] + 1)
        self.data = [data]
        for i in range(1, m):
            d = [0] * n
            w = 2**i
            for j in range(0, n, w * 2):
                c = min(j + w, n)
                d[c - 1] = data[c - 1]
                for k in range(c - 2, j - 1, -1):
                    d[k] = f(data[k], d[k + 1])
                if c < n:
                    d[c] = data[c]
                    for k in range(c + 1, min(j + w * 2, n)):
                        d[k] = f(data[k], d[k - 1])
            self.data.append(d)

    def get(self, l, r):  # [l,r)
        r -= 1
        if l == r:
            return self.data[0][l]
        d = self.data[self.h[l ^ r]]
        return self.f(d[l], d[r])


def main():
    from fractions import gcd

    n, *a = list(map(int, open(0).read().split()))
    f = DisjointSparseTable(a, gcd).get
    m = max(f(1, n), f(0, n - 1))
    for i in range(n - 2):
        m = max(m, gcd(f(0, i + 1), f(i + 2, n)))
    print(m)


main()

-class SegTree: -    def __init__(self, data, unit, f): -        self.size = n = len(data) -        self.data = [unit for _ in range(n)] + data -        for i in range(n - 1, 0, -1): -            self.data[i] = f(self.data[i + i], self.data[i - ~i]) -        self.unit = unit +class DisjointSparseTable: +    def __init__(self, data, f): +        from math import ceil, log  # 2 + +        self.n = n = len(data) +        m = ceil(log(n, 2))  # ceil(log2(n)) +        self.h = [0, 0] +        for i in range(2, 2**m): +            self.h.append(self.h[i // 2] + 1) +        self.data = [data] +        for i in range(1, m): +            d = [0] * n +            w = 2**i +            for j in range(0, n, w * 2): +                c = min(j + w, n) +                d[c - 1] = data[c - 1] +                for k in range(c - 2, j - 1, -1): +                    d[k] = f(data[k], d[k + 1]) +                if c < n: +                    d[c] = data[c] +                    for k in range(c + 1, min(j + w * 2, n)): +                        d[k] = f(data[k], d[k - 1]) +            self.data.append(d) -    def update(self, i, x): -        c, f = self.data, self.f -        i += self.size -        c[i] = x -        while i > 1: -            i >>= 1 -            c[i] = f(c[i + i], c[i - ~i]) - -    def add(self, i, x): -        c, f = self.data, self.f -        i += self.size -        c[i] = f(c[i], x) -        while i > 1: -            i >>= 1 -            c[i] = f(c[i + i], c[i - ~i]) - -    def query(self, l, r): -        c, f = self.data, self.f -        x, y = self.unit, self.unit -        l += self.size -        r += self.size -        while l < r: -            if l & 1: -                x = f(x, c[l]) -                l += 1 -            if r & 1: -                r -= 1 -                y = f(c[r], y) -            l >>= 1 -            r >>= 1 -        return f(x, y) +    def get(self, l, r):  # [l,r) +        r -= 1 +        if l == r: +            return self.data[0][l] +        d = self.data[self.h[l ^ r]] +        return self.f(d[l], d[r]) -    f = SegTree(a, 0, gcd).query +    f = DisjointSparseTable(a, gcd).get