import sys

input = sys.stdin.readline



n = int(eval(input()))

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



def gcd(x,y):

  while y:

    x, y = y, x%y

  return x



ll, lr = [0]*n, [0]*n

ll[0], lr[n-1] = a[0], a[n-1]

for i in range(1,n):

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

  lr[n-i-1] = gcd(lr[n-i], a[n-i-1])



print((max(ll[n-2], lr[1], *[gcd(l,r) for l,r in zip(ll[:n-2], lr[2:])])))
n=int(eval(input()))

a=[*list(map(int,input().split()))]

from math import *

l=a.copy()

r=a.copy()

for i in range(n-1):

  l[i+1]=gcd(l[i],l[i+1])

  r[-i-2]=gcd(r[-i-1],r[-i-2])

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

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

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

print(a)
import sys

input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))


def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


ll, lr = [0] * n, [0] * n
ll[0], lr[n - 1] = a[0], a[n - 1]
for i in range(1, n):
    ll[i] = gcd(ll[i - 1], a[i])
    lr[n - i - 1] = gcd(lr[n - i], a[n - i - 1])
print((max(ll[n - 2], lr[1], *[gcd(l, r) for l, r in zip(ll[: n - 2], lr[2:])])))

n = int(eval(input()))
a = [*list(map(int, input().split()))]
from math import *

l = a.copy()
r = a.copy()
for i in range(n - 1):
    l[i + 1] = gcd(l[i], l[i + 1])
    r[-i - 2] = gcd(r[-i - 1], r[-i - 2])
a = max(l[-2], r[1])
for i in range(1, n - 1):
    a = max(a, gcd(l[i - 1], r[i + 1]))
print(a)

-import sys +n = int(eval(input())) +a = [*list(map(int, input().split()))] +from math import * -input = sys.stdin.readline -n = int(eval(input())) -a = list(map(int, input().split())) - - -def gcd(x, y): -    while y: -        x, y = y, x % y -    return x - - -ll, lr = [0] * n, [0] * n -ll[0], lr[n - 1] = a[0], a[n - 1] -for i in range(1, n): -    ll[i] = gcd(ll[i - 1], a[i]) -    lr[n - i - 1] = gcd(lr[n - i], a[n - i - 1]) -print((max(ll[n - 2], lr[1], *[gcd(l, r) for l, r in zip(ll[: n - 2], lr[2:])]))) +l = a.copy() +r = a.copy() +for i in range(n - 1): +    l[i + 1] = gcd(l[i], l[i + 1]) +    r[-i - 2] = gcd(r[-i - 1], r[-i - 2]) +a = max(l[-2], r[1]) +for i in range(1, n - 1): +    a = max(a, gcd(l[i - 1], r[i + 1])) +print(a)