# 最大公約数

def gcd(a, b):

    while b:

        a, b = b, a % b

    return a





N = int(eval(input()))

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





L = [0 for _ in range(N)]

R = [0 for _ in range(N)]



L[0] = A[0]

R[N-1] = A[N-1]



for i in range(1, N):

    L[i] = gcd(L[i-1], A[i])



for i in reversed(list(range(N-1))):

    R[i] = gcd(R[i+1], A[i])



ans = 0

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 itertools import accumulate

from fractions import gcd





N = int(eval(input()))

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



cum_gcd_l = list(accumulate(A, gcd))

cum_gcd_r = list(accumulate(reversed(A), gcd))



ans = 0

for i in range(N):

    if i == 0:

        tmp = cum_gcd_r[-2]

    elif i == N-1:

        tmp = cum_gcd_l[-2]

    else:

        tmp = gcd(cum_gcd_l[i-1], cum_gcd_r[N-i-2])

    ans = max(tmp, ans)



print(ans)



# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


N = int(eval(input()))
A = list(map(int, input().split()))
L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
L[0] = A[0]
R[N - 1] = A[N - 1]
for i in range(1, N):
    L[i] = gcd(L[i - 1], A[i])
for i in reversed(list(range(N - 1))):
    R[i] = gcd(R[i + 1], A[i])
ans = 0
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 itertools import accumulate
from fractions import gcd

N = int(eval(input()))
A = list(map(int, input().split()))
cum_gcd_l = list(accumulate(A, gcd))
cum_gcd_r = list(accumulate(reversed(A), gcd))
ans = 0
for i in range(N):
    if i == 0:
        tmp = cum_gcd_r[-2]
    elif i == N - 1:
        tmp = cum_gcd_l[-2]
    else:
        tmp = gcd(cum_gcd_l[i - 1], cum_gcd_r[N - i - 2])
    ans = max(tmp, ans)
print(ans)

-# 最大公約数 -def gcd(a, b): -    while b: -        a, b = b, a % b -    return a - +from itertools import accumulate +from fractions import gcd -L = [0 for _ in range(N)] -R = [0 for _ in range(N)] -L[0] = A[0] -R[N - 1] = A[N - 1] -for i in range(1, N): -    L[i] = gcd(L[i - 1], A[i]) -for i in reversed(list(range(N - 1))): -    R[i] = gcd(R[i + 1], A[i]) +cum_gcd_l = list(accumulate(A, gcd)) +cum_gcd_r = list(accumulate(reversed(A), gcd)) -        ans = max(ans, R[i + 1]) +        tmp = cum_gcd_r[-2] -        ans = max(ans, L[i - 1]) +        tmp = cum_gcd_l[-2] -        ans = max(ans, gcd(L[i - 1], R[i + 1])) +        tmp = gcd(cum_gcd_l[i - 1], cum_gcd_r[N - i - 2]) +    ans = max(tmp, ans)