import sys

from fractions import gcd

from collections import deque



N=eval(input())

A=list(map(int, sys.stdin.readline().split()))



L=deque()



for i in range(N):

	if i==0:

		L.append(A[i])

	else:

		L.append( gcd(A[i],L[i-1]) )



R=deque()



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

	if i==N-1:

		R.appendleft(A[i])

	else:

		R.appendleft( gcd(A[i],R[0]) )



ans=float("-inf")

for i in range(N):

	if i==0:

		t=R[i+1]

	elif i==N-1:

		t=L[i-1]

	else:

		t=gcd(L[i-1], R[i+1])

	ans=max(ans, t)



print(ans)

import sys

from fractions import gcd



N=eval(input())

A=list(map(int, sys.stdin.readline().split()))



L=[]

R=[]



for i,a in enumerate(A):

    if i==0:

        L.append(a)

    else:

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



for i,a in enumerate(A[::-1]):

    if i==0:

        R.append(a)

    else:

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

R=R[::-1]



ans=float("-inf")

for i in range(N):

    if i==0:

        ans=max(ans,R[i+1])

    elif i==N-1:

        ans=max(ans,L[i-1])

    else:

        ans=max( ans,gcd(L[i-1],R[i+1]) )



print(ans)

import sys
from fractions import gcd
from collections import deque

N = eval(input())
A = list(map(int, sys.stdin.readline().split()))
L = deque()
for i in range(N):
    if i == 0:
        L.append(A[i])
    else:
        L.append(gcd(A[i], L[i - 1]))
R = deque()
for i in range(N - 1, -1, -1):
    if i == N - 1:
        R.appendleft(A[i])
    else:
        R.appendleft(gcd(A[i], R[0]))
ans = float("-inf")
for i in range(N):
    if i == 0:
        t = R[i + 1]
    elif i == N - 1:
        t = L[i - 1]
    else:
        t = gcd(L[i - 1], R[i + 1])
    ans = max(ans, t)
print(ans)

import sys
from fractions import gcd

N = eval(input())
A = list(map(int, sys.stdin.readline().split()))
L = []
R = []
for i, a in enumerate(A):
    if i == 0:
        L.append(a)
    else:
        L.append(gcd(L[-1], a))
for i, a in enumerate(A[::-1]):
    if i == 0:
        R.append(a)
    else:
        R.append(gcd(R[-1], a))
R = R[::-1]
ans = float("-inf")
for i in range(N):
    if i == 0:
        ans = max(ans, R[i + 1])
    elif i == N - 1:
        ans = max(ans, L[i - 1])
    else:
        ans = max(ans, gcd(L[i - 1], R[i + 1]))
print(ans)

-from collections import deque -L = deque() -for i in range(N): +L = [] +R = [] +for i, a in enumerate(A): -        L.append(A[i]) +        L.append(a) -        L.append(gcd(A[i], L[i - 1])) -R = deque() -for i in range(N - 1, -1, -1): -    if i == N - 1: -        R.appendleft(A[i]) +        L.append(gcd(L[-1], a)) +for i, a in enumerate(A[::-1]): +    if i == 0: +        R.append(a) -        R.appendleft(gcd(A[i], R[0])) +        R.append(gcd(R[-1], a)) +R = R[::-1] -        t = R[i + 1] +        ans = max(ans, R[i + 1]) -        t = L[i - 1] +        ans = max(ans, L[i - 1]) -        t = gcd(L[i - 1], R[i + 1]) -    ans = max(ans, t) +        ans = max(ans, gcd(L[i - 1], R[i + 1]))