printn = lambda x: print(x,end='')

inn = lambda : int(input())

inl   = lambda: list(map(int, input().split()))

inm   = lambda:      map(int, input().split())

ins = lambda : input().strip()

DBG = True # and False

BIG = 10**18

R = 10**9 + 7



def ddprint(x):

  if DBG:

    print(x)





# # # # class Segtree # # # #



#      0

#   1     2

# 3   4  5  6

#       :

# leaf i - n-1+i

# parent   - (i-1)//2

# children - 2*i+1, 2*i+2



class Segtree:

    # modify UNIT and oper depending on the reduce operation



    #UNIT = 0  # sum/or:0 and:fff..f min:BIG max:-BIG gcd:0 lcm:1 ..



    #@classmethod

    #def oper(c,x,y):

    #    return x|y  # sum:+ or/and/min/max/gcd/lcm:(same)



    # call like this: sgt = Segtree(n, 0, lambda x,y: max(x,y))



    def __init__(s,l,unit,oper):

        s.unit = unit

        s.oper = oper

        s.n = 1

        while s.n<l:

            s.n *= 2

        s.ary = [s.unit for i in range(2*s.n-1)]



    def get(s,i):

        return s.ary[i+s.n-1]



    def set(s,i,v):

        k = i+s.n-1

        s.ary[k] = v

        while k>0:

            k = (k-1)//2

            s.ary[k] = s.oper( \

                        s.ary[2*k+1], s.ary[2*k+2])



    def setary(s,a):

        for i,v in enumerate(a):

            s.ary[i+s.n-1] = v

        for k in range(s.n-2,-1,-1):

            s.ary[k] = s.oper( \

                        s.ary[2*k+1], s.ary[2*k+2])



    def query(s,x,y):

        l = x+s.n-1

        r = y+s.n-1

        res = s.unit

        while l<r:

            if not l%2:

                res = s.oper(res,s.ary[l])

                l += 1

            if not r%2:

                r -= 1

                res = s.oper(res,s.ary[r])

            l >>= 1

            r >>= 1

        return res





# # # # class Segtree end # # # #



from fractions import gcd

n = inn()

a = inl()

sgt = Segtree(n,0,gcd)

sgt.setary(a)

mx = max(sgt.query(1,n), sgt.query(0,n-1))

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

    g = gcd(sgt.query(0,i),sgt.query(i+1,n))

    mx = max(mx,g)

print(mx)

printn = lambda x: print(x,end='')

inn = lambda : int(input())

inl   = lambda: list(map(int, input().split()))

inm   = lambda:      map(int, input().split())

ins = lambda : input().strip()

DBG = True # and False

BIG = 10**18

R = 10**9 + 7



def ddprint(x):

  if DBG:

    print(x)



from fractions import gcd

n = inn()

a = inl()

l = [a[0]]*n

for i in range(1,n):

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

r = [a[n-1]]*n

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

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

mx = max(l[n-2],r[1])

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

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

print(mx)

printn = lambda x: print(x, end="")
inn = lambda: int(input())
inl = lambda: list(map(int, input().split()))
inm = lambda: map(int, input().split())
ins = lambda: input().strip()
DBG = True  # and False
BIG = 10**18
R = 10**9 + 7


def ddprint(x):
    if DBG:
        print(x)


# # # # class Segtree # # # #
#      0
#   1     2
# 3   4  5  6
#       :
# leaf i - n-1+i
# parent   - (i-1)//2
# children - 2*i+1, 2*i+2
class Segtree:
    # modify UNIT and oper depending on the reduce operation
    # UNIT = 0  # sum/or:0 and:fff..f min:BIG max:-BIG gcd:0 lcm:1 ..
    # @classmethod
    # def oper(c,x,y):
    #    return x|y  # sum:+ or/and/min/max/gcd/lcm:(same)
    # call like this: sgt = Segtree(n, 0, lambda x,y: max(x,y))
    def __init__(s, l, unit, oper):
        s.unit = unit
        s.oper = oper
        s.n = 1
        while s.n < l:
            s.n *= 2
        s.ary = [s.unit for i in range(2 * s.n - 1)]

    def get(s, i):
        return s.ary[i + s.n - 1]

    def set(s, i, v):
        k = i + s.n - 1
        s.ary[k] = v
        while k > 0:
            k = (k - 1) // 2
            s.ary[k] = s.oper(s.ary[2 * k + 1], s.ary[2 * k + 2])

    def setary(s, a):
        for i, v in enumerate(a):
            s.ary[i + s.n - 1] = v
        for k in range(s.n - 2, -1, -1):
            s.ary[k] = s.oper(s.ary[2 * k + 1], s.ary[2 * k + 2])

    def query(s, x, y):
        l = x + s.n - 1
        r = y + s.n - 1
        res = s.unit
        while l < r:
            if not l % 2:
                res = s.oper(res, s.ary[l])
                l += 1
            if not r % 2:
                r -= 1
                res = s.oper(res, s.ary[r])
            l >>= 1
            r >>= 1
        return res


# # # # class Segtree end # # # #
from fractions import gcd

n = inn()
a = inl()
sgt = Segtree(n, 0, gcd)
sgt.setary(a)
mx = max(sgt.query(1, n), sgt.query(0, n - 1))
for i in range(1, n - 1):
    g = gcd(sgt.query(0, i), sgt.query(i + 1, n))
    mx = max(mx, g)
print(mx)

printn = lambda x: print(x, end="")
inn = lambda: int(input())
inl = lambda: list(map(int, input().split()))
inm = lambda: map(int, input().split())
ins = lambda: input().strip()
DBG = True  # and False
BIG = 10**18
R = 10**9 + 7


def ddprint(x):
    if DBG:
        print(x)


from fractions import gcd

n = inn()
a = inl()
l = [a[0]] * n
for i in range(1, n):
    l[i] = gcd(l[i - 1], a[i])
r = [a[n - 1]] * n
for i in range(n - 2, -1, -1):
    r[i] = gcd(r[i + 1], a[i])
mx = max(l[n - 2], r[1])
for i in range(1, n - 1):
    mx = max(mx, gcd(l[i - 1], r[i + 1]))
print(mx)

-# # # # class Segtree # # # # -#      0 -#   1     2 -# 3   4  5  6 -#       : -# leaf i - n-1+i -# parent   - (i-1)//2 -# children - 2*i+1, 2*i+2 -class Segtree: -    # modify UNIT and oper depending on the reduce operation -    # UNIT = 0  # sum/or:0 and:fff..f min:BIG max:-BIG gcd:0 lcm:1 .. -    # @classmethod -    # def oper(c,x,y): -    #    return x|y  # sum:+ or/and/min/max/gcd/lcm:(same) -    # call like this: sgt = Segtree(n, 0, lambda x,y: max(x,y)) -    def __init__(s, l, unit, oper): -        s.unit = unit -        s.oper = oper -        s.n = 1 -        while s.n < l: -            s.n *= 2 -        s.ary = [s.unit for i in range(2 * s.n - 1)] - -    def get(s, i): -        return s.ary[i + s.n - 1] - -    def set(s, i, v): -        k = i + s.n - 1 -        s.ary[k] = v -        while k > 0: -            k = (k - 1) // 2 -            s.ary[k] = s.oper(s.ary[2 * k + 1], s.ary[2 * k + 2]) - -    def setary(s, a): -        for i, v in enumerate(a): -            s.ary[i + s.n - 1] = v -        for k in range(s.n - 2, -1, -1): -            s.ary[k] = s.oper(s.ary[2 * k + 1], s.ary[2 * k + 2]) - -    def query(s, x, y): -        l = x + s.n - 1 -        r = y + s.n - 1 -        res = s.unit -        while l < r: -            if not l % 2: -                res = s.oper(res, s.ary[l]) -                l += 1 -            if not r % 2: -                r -= 1 -                res = s.oper(res, s.ary[r]) -            l >>= 1 -            r >>= 1 -        return res - - -# # # # class Segtree end # # # # -sgt = Segtree(n, 0, gcd) -sgt.setary(a) -mx = max(sgt.query(1, n), sgt.query(0, n - 1)) +l = [a[0]] * n +for i in range(1, n): +    l[i] = gcd(l[i - 1], a[i]) +r = [a[n - 1]] * n +for i in range(n - 2, -1, -1): +    r[i] = gcd(r[i + 1], a[i]) +mx = max(l[n - 2], r[1]) -    g = gcd(sgt.query(0, i), sgt.query(i + 1, n)) -    mx = max(mx, g) +    mx = max(mx, gcd(l[i - 1], r[i + 1]))