import sys



def gcd(a, b):

    while b:

        a, b = b, a%b

    return a



n=int(eval(input()))

al=input().split()

al_i = [int(s) for s in al]



if (n == 2):

   print((max(al_i[0],al_i[1])))

   sys.exit()



fg = [0] * n

bg = [0] * n



for x in range(n):

   if (x == 0):

       fg[0] = al_i[0]

       y = 1

   else:

      while y <= x:

         fg[y] = gcd(fg[y-1], al_i[y])

         y += 1



for x in range(n):

   if (x == 0):

      bg[0] = al_i[n-1]

      y = 1

   else:

      while y <= x:

         bg[y] = gcd(bg[y-1], al_i[n-1-y])

         y += 1



m = 0

gm = 0



for x in range(n):

   if (x == 0):

      g = bg[n-2]

   elif (x == n-1):

      g = fg[n-2]

   else:

      g = gcd(fg[x-1],bg[n-2-x])

   if (g > gm):

      gm = g



print(gm)

def gcd(a, b):

    while b:

        a, b = b, a%b

    return a



n=int(eval(input()))

al=[int(x) for x in input().split()]



fg = [0] * n

bg = [0] * n



fg[0] = al[0]

bg[0] = al[n-1]



for x in range(1,n):

    fg[x] = gcd(fg[x-1], al[x])

    bg[x] = gcd(bg[x-1], al[n-1-x])



gm = max(bg[n-2], fg[n-2])



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

   g = gcd(fg[x-1],bg[n-2-x])

   if (g > gm):

      gm = g



print(gm)
import sys


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


n = int(eval(input()))
al = input().split()
al_i = [int(s) for s in al]
if n == 2:
    print((max(al_i[0], al_i[1])))
    sys.exit()
fg = [0] * n
bg = [0] * n
for x in range(n):
    if x == 0:
        fg[0] = al_i[0]
        y = 1
    else:
        while y <= x:
            fg[y] = gcd(fg[y - 1], al_i[y])
            y += 1
for x in range(n):
    if x == 0:
        bg[0] = al_i[n - 1]
        y = 1
    else:
        while y <= x:
            bg[y] = gcd(bg[y - 1], al_i[n - 1 - y])
            y += 1
m = 0
gm = 0
for x in range(n):
    if x == 0:
        g = bg[n - 2]
    elif x == n - 1:
        g = fg[n - 2]
    else:
        g = gcd(fg[x - 1], bg[n - 2 - x])
    if g > gm:
        gm = g
print(gm)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


n = int(eval(input()))
al = [int(x) for x in input().split()]
fg = [0] * n
bg = [0] * n
fg[0] = al[0]
bg[0] = al[n - 1]
for x in range(1, n):
    fg[x] = gcd(fg[x - 1], al[x])
    bg[x] = gcd(bg[x - 1], al[n - 1 - x])
gm = max(bg[n - 2], fg[n - 2])
for x in range(1, n - 1):
    g = gcd(fg[x - 1], bg[n - 2 - x])
    if g > gm:
        gm = g
print(gm)

-import sys - - -al = input().split() -al_i = [int(s) for s in al] -if n == 2: -    print((max(al_i[0], al_i[1]))) -    sys.exit() +al = [int(x) for x in input().split()] -for x in range(n): -    if x == 0: -        fg[0] = al_i[0] -        y = 1 -    else: -        while y <= x: -            fg[y] = gcd(fg[y - 1], al_i[y]) -            y += 1 -for x in range(n): -    if x == 0: -        bg[0] = al_i[n - 1] -        y = 1 -    else: -        while y <= x: -            bg[y] = gcd(bg[y - 1], al_i[n - 1 - y]) -            y += 1 -m = 0 -gm = 0 -for x in range(n): -    if x == 0: -        g = bg[n - 2] -    elif x == n - 1: -        g = fg[n - 2] -    else: -        g = gcd(fg[x - 1], bg[n - 2 - x]) +fg[0] = al[0] +bg[0] = al[n - 1] +for x in range(1, n): +    fg[x] = gcd(fg[x - 1], al[x]) +    bg[x] = gcd(bg[x - 1], al[n - 1 - x]) +gm = max(bg[n - 2], fg[n - 2]) +for x in range(1, n - 1): +    g = gcd(fg[x - 1], bg[n - 2 - x])