from fractions import gcd

N = int(eval(input()))

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



class SegTree:

    def __init__(self,arr,func,unit):

        self.func = func

        self.unit = unit

        n = 1

        while n < len(arr):

            n *= 2

        self.n = n

        nodes = [unit]*(2*n-1)

        nodes[n-1:n-1+len(arr)] = arr

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

            nodes[i] = func(nodes[2*i+1],nodes[2*i+2])

        self.nodes = nodes



    def update(self,i,val):

        i += self.n-1

        self.nodes[i] = val

        while i >= 0:

            i = (i - 1) // 2

            self.nodes[i] = self.func(self.nodes[2*i+1], self.nodes[2*i+2])



    def query(self,l,r):

        l += self.n

        r += self.n

        s = self.unit

        while l < r:

            if r & 1:

                r -= 1

                s = self.func(s, self.nodes[r-1])

            if l & 1:

                s = self.func(s, self.nodes[l-1])

                l += 1

            l >>= 1

            r >>= 1

        return s



segt = SegTree(A, lambda x,y:gcd(x,y), 0)

ans = 0

for i in range(N):

    l = segt.query(0,i)

    r = segt.query(i+1,N)

    g = gcd(l,r)

    ans = max(ans, g)

print(ans)
from fractions import gcd

N = int(eval(input()))

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



lc = [0]

for a in A:

    lc.append(gcd(lc[-1], a))

rc = [0]

for a in A[::-1]:

    rc.append(gcd(rc[-1], a))

rc.reverse()



ans = 0

for l,r in zip(lc,rc[1:]):

    g = gcd(l,r)

    ans = max(ans, g)

print(ans)
from fractions import gcd

N = int(eval(input()))
A = list(map(int, input().split()))


class SegTree:
    def __init__(self, arr, func, unit):
        self.func = func
        self.unit = unit
        n = 1
        while n < len(arr):
            n *= 2
        self.n = n
        nodes = [unit] * (2 * n - 1)
        nodes[n - 1 : n - 1 + len(arr)] = arr
        for i in range(n - 2, -1, -1):
            nodes[i] = func(nodes[2 * i + 1], nodes[2 * i + 2])
        self.nodes = nodes

    def update(self, i, val):
        i += self.n - 1
        self.nodes[i] = val
        while i >= 0:
            i = (i - 1) // 2
            self.nodes[i] = self.func(self.nodes[2 * i + 1], self.nodes[2 * i + 2])

    def query(self, l, r):
        l += self.n
        r += self.n
        s = self.unit
        while l < r:
            if r & 1:
                r -= 1
                s = self.func(s, self.nodes[r - 1])
            if l & 1:
                s = self.func(s, self.nodes[l - 1])
                l += 1
            l >>= 1
            r >>= 1
        return s


segt = SegTree(A, lambda x, y: gcd(x, y), 0)
ans = 0
for i in range(N):
    l = segt.query(0, i)
    r = segt.query(i + 1, N)
    g = gcd(l, r)
    ans = max(ans, g)
print(ans)

from fractions import gcd

N = int(eval(input()))
A = list(map(int, input().split()))
lc = [0]
for a in A:
    lc.append(gcd(lc[-1], a))
rc = [0]
for a in A[::-1]:
    rc.append(gcd(rc[-1], a))
rc.reverse()
ans = 0
for l, r in zip(lc, rc[1:]):
    g = gcd(l, r)
    ans = max(ans, g)
print(ans)

- - -class SegTree: -    def __init__(self, arr, func, unit): -        self.func = func -        self.unit = unit -        n = 1 -        while n < len(arr): -            n *= 2 -        self.n = n -        nodes = [unit] * (2 * n - 1) -        nodes[n - 1 : n - 1 + len(arr)] = arr -        for i in range(n - 2, -1, -1): -            nodes[i] = func(nodes[2 * i + 1], nodes[2 * i + 2]) -        self.nodes = nodes - -    def update(self, i, val): -        i += self.n - 1 -        self.nodes[i] = val -        while i >= 0: -            i = (i - 1) // 2 -            self.nodes[i] = self.func(self.nodes[2 * i + 1], self.nodes[2 * i + 2]) - -    def query(self, l, r): -        l += self.n -        r += self.n -        s = self.unit -        while l < r: -            if r & 1: -                r -= 1 -                s = self.func(s, self.nodes[r - 1]) -            if l & 1: -                s = self.func(s, self.nodes[l - 1]) -                l += 1 -            l >>= 1 -            r >>= 1 -        return s - - -segt = SegTree(A, lambda x, y: gcd(x, y), 0) +lc = [0] +for a in A: +    lc.append(gcd(lc[-1], a)) +rc = [0] +for a in A[::-1]: +    rc.append(gcd(rc[-1], a)) +rc.reverse() -for i in range(N): -    l = segt.query(0, i) -    r = segt.query(i + 1, N) +for l, r in zip(lc, rc[1:]):