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 SWAG():

    __slots__='unit','f','fold_r','fold_l','data_r','data_l'

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

        self.unit=unit

        self.f=f

        self.construct(data)

    def construct(self,data):

        self.fold_r=[self.unit]

        self.fold_l=[self.unit]

        self.data_r=[]

        self.data_l=[]

        sep=0--len(data)//2

        for t in data[sep:]:

            self.append(t)

        for t in data[sep-1::-1]:

            self.appendleft(t)

    def append(self,x):

        self.fold_r.append(self.f(self.fold_r[-1],x))

        self.data_r.append(x)

    def appendleft(self,x):

        self.fold_l.append(self.f(self.fold_l[-1],x))

        self.data_l.append(x)

    def pop(self):

        if not self.data_r:

            self.construct(self.data_l[::-1])

        if not self.data_r:

            return self.popleft()

        self.fold_r.pop()

        return self.data_r.pop()

    def popleft(self):

        if not self.data_l:

            self.construct(self.data_r)

        if not self.data_l:

            return False

        self.fold_l.pop()

        return self.data_l.pop()

    def fold_all(self):

        return self.f(self.fold_r[-1],self.fold_l[-1])

def main():

    from fractions import gcd

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

    l,r=SWAG(0,gcd,[]),SWAG(0,gcd,a[1:])

    m=r.fold_all()

    for i in range(n-1):

        l.append(a[i])

        r.popleft()

        m=max(m,gcd(l.fold_all(),r.fold_all()))

    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 SWAG:
    __slots__ = "unit", "f", "fold_r", "fold_l", "data_r", "data_l"

    def __init__(self, unit, f, data):
        self.unit = unit
        self.f = f
        self.construct(data)

    def construct(self, data):
        self.fold_r = [self.unit]
        self.fold_l = [self.unit]
        self.data_r = []
        self.data_l = []
        sep = 0 - -len(data) // 2
        for t in data[sep:]:
            self.append(t)
        for t in data[sep - 1 :: -1]:
            self.appendleft(t)

    def append(self, x):
        self.fold_r.append(self.f(self.fold_r[-1], x))
        self.data_r.append(x)

    def appendleft(self, x):
        self.fold_l.append(self.f(self.fold_l[-1], x))
        self.data_l.append(x)

    def pop(self):
        if not self.data_r:
            self.construct(self.data_l[::-1])
        if not self.data_r:
            return self.popleft()
        self.fold_r.pop()
        return self.data_r.pop()

    def popleft(self):
        if not self.data_l:
            self.construct(self.data_r)
        if not self.data_l:
            return False
        self.fold_l.pop()
        return self.data_l.pop()

    def fold_all(self):
        return self.f(self.fold_r[-1], self.fold_l[-1])


def main():
    from fractions import gcd

    n, *a = list(map(int, open(0).read().split()))
    l, r = SWAG(0, gcd, []), SWAG(0, gcd, a[1:])
    m = r.fold_all()
    for i in range(n - 1):
        l.append(a[i])
        r.popleft()
        m = max(m, gcd(l.fold_all(), r.fold_all()))
    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]) +class SWAG: +    __slots__ = "unit", "f", "fold_r", "fold_l", "data_r", "data_l" + +    def __init__(self, unit, f, data): +        self.construct(data) -    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 construct(self, data): +        self.fold_r = [self.unit] +        self.fold_l = [self.unit] +        self.data_r = [] +        self.data_l = [] +        sep = 0 - -len(data) // 2 +        for t in data[sep:]: +            self.append(t) +        for t in data[sep - 1 :: -1]: +            self.appendleft(t) -    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 append(self, x): +        self.fold_r.append(self.f(self.fold_r[-1], x)) +        self.data_r.append(x) -    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 appendleft(self, x): +        self.fold_l.append(self.f(self.fold_l[-1], x)) +        self.data_l.append(x) + +    def pop(self): +        if not self.data_r: +            self.construct(self.data_l[::-1]) +        if not self.data_r: +            return self.popleft() +        self.fold_r.pop() +        return self.data_r.pop() + +    def popleft(self): +        if not self.data_l: +            self.construct(self.data_r) +        if not self.data_l: +            return False +        self.fold_l.pop() +        return self.data_l.pop() + +    def fold_all(self): +        return self.f(self.fold_r[-1], self.fold_l[-1]) -    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))) +    l, r = SWAG(0, gcd, []), SWAG(0, gcd, a[1:]) +    m = r.fold_all() +    for i in range(n - 1): +        l.append(a[i]) +        r.popleft() +        m = max(m, gcd(l.fold_all(), r.fold_all()))