import math

n=int(eval(input()))

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

a.sort()

lr=[0]*n

rl=[0]*n



for i in range(n):

  if i==0:

    g=a[0]

    lr[0]=g

  else:

    g=math.gcd(a[i],g)

    lr[i]=g

    

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

  if n-1==i:

    g=a[n-1]

    rl[n-1]=g

  else:

    g=math.gcd(a[i],g)

    rl[i]=g  

hantei=0

ans=0

#print(lr)

#print(rl)

for i in range(n):

  if i==0:

    hantei=rl[1]

  elif i==n-1:

    hantei=lr[n-2]

  else:

    hantei=math.gcd(lr[i-1],rl[i+1])

  if ans<=hantei:

    ans=hantei

    

print(ans)
import math

n=int(eval(input()))

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



ra=list(reversed(a))



left=[]

right=[]

right.append(ra[0])

left.append(a[0])



if n>2:

  k=math.gcd(a[0],a[1])

  left.append(k)

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

    k=math.gcd(k,a[i])

    left.append(k)



  k=math.gcd(ra[0],ra[1])

  right.append(k)

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

    k=math.gcd(k,ra[i])

    right.append(k)



  ans=[right[-1]]

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

    ans.append(math.gcd(left[i-1],right[len(right)-i-1]))

  ans.append(left[-1])

  print((max(ans)))

else:

  print((max(a[1],a[0])))
import math

n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
lr = [0] * n
rl = [0] * n
for i in range(n):
    if i == 0:
        g = a[0]
        lr[0] = g
    else:
        g = math.gcd(a[i], g)
        lr[i] = g
for i in range(n - 1, 0, -1):
    if n - 1 == i:
        g = a[n - 1]
        rl[n - 1] = g
    else:
        g = math.gcd(a[i], g)
        rl[i] = g
hantei = 0
ans = 0
# print(lr)
# print(rl)
for i in range(n):
    if i == 0:
        hantei = rl[1]
    elif i == n - 1:
        hantei = lr[n - 2]
    else:
        hantei = math.gcd(lr[i - 1], rl[i + 1])
    if ans <= hantei:
        ans = hantei
print(ans)

import math

n = int(eval(input()))
a = list(map(int, input().split()))
ra = list(reversed(a))
left = []
right = []
right.append(ra[0])
left.append(a[0])
if n > 2:
    k = math.gcd(a[0], a[1])
    left.append(k)
    for i in range(2, n - 1):
        k = math.gcd(k, a[i])
        left.append(k)
    k = math.gcd(ra[0], ra[1])
    right.append(k)
    for i in range(2, n - 1):
        k = math.gcd(k, ra[i])
        right.append(k)
    ans = [right[-1]]
    for i in range(1, n - 1):
        ans.append(math.gcd(left[i - 1], right[len(right) - i - 1]))
    ans.append(left[-1])
    print((max(ans)))
else:
    print((max(a[1], a[0])))

-a.sort() -lr = [0] * n -rl = [0] * n -for i in range(n): -    if i == 0: -        g = a[0] -        lr[0] = g -    else: -        g = math.gcd(a[i], g) -        lr[i] = g -for i in range(n - 1, 0, -1): -    if n - 1 == i: -        g = a[n - 1] -        rl[n - 1] = g -    else: -        g = math.gcd(a[i], g) -        rl[i] = g -hantei = 0 -ans = 0 -# print(lr) -# print(rl) -for i in range(n): -    if i == 0: -        hantei = rl[1] -    elif i == n - 1: -        hantei = lr[n - 2] -    else: -        hantei = math.gcd(lr[i - 1], rl[i + 1]) -    if ans <= hantei: -        ans = hantei -print(ans) +ra = list(reversed(a)) +left = [] +right = [] +right.append(ra[0]) +left.append(a[0]) +if n > 2: +    k = math.gcd(a[0], a[1]) +    left.append(k) +    for i in range(2, n - 1): +        k = math.gcd(k, a[i]) +        left.append(k) +    k = math.gcd(ra[0], ra[1]) +    right.append(k) +    for i in range(2, n - 1): +        k = math.gcd(k, ra[i]) +        right.append(k) +    ans = [right[-1]] +    for i in range(1, n - 1): +        ans.append(math.gcd(left[i - 1], right[len(right) - i - 1])) +    ans.append(left[-1]) +    print((max(ans))) +else: +    print((max(a[1], a[0])))