"""

配列の値を書き換える＝＝削除すると同義

削除する値を一つ決め、それを区切りに右と左の配列に分け、GCDを求める

更に左右のGCDをマージしGCDを求め、最大値が答え

"""

import functools, fractions



N = int(eval(input()))

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

L = [0]*(N+1)

R = [0]*(N+1)



for i in range(N):

  L[i+1] = fractions.gcd(L[i], A[i])



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

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

  

ans = 0

for i in range(N):

  l = L[i]

  r = R[i+1]

  ans = max(ans, fractions.gcd(l, r))

print(ans)  
from itertools import *

import fractions

 

N = int(eval(input()))

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

 

L = list(accumulate([0]+A, fractions.gcd))

R = list(accumulate([0]+A[::-1], fractions.gcd))

 

print((max(fractions.gcd(s, t) for s, t in zip(L, R[::-1][1:]))))
"""
配列の値を書き換える＝＝削除すると同義
削除する値を一つ決め、それを区切りに右と左の配列に分け、GCDを求める
更に左右のGCDをマージしGCDを求め、最大値が答え
"""
import functools, fractions

N = int(eval(input()))
A = list(map(int, input().split()))
L = [0] * (N + 1)
R = [0] * (N + 1)
for i in range(N):
    L[i + 1] = fractions.gcd(L[i], A[i])
for i in range(N - 1, 0, -1):
    R[i] = fractions.gcd(R[i + 1], A[i])
ans = 0
for i in range(N):
    l = L[i]
    r = R[i + 1]
    ans = max(ans, fractions.gcd(l, r))
print(ans)

from itertools import *
import fractions

N = int(eval(input()))
A = list(map(int, input().split()))
L = list(accumulate([0] + A, fractions.gcd))
R = list(accumulate([0] + A[::-1], fractions.gcd))
print((max(fractions.gcd(s, t) for s, t in zip(L, R[::-1][1:]))))

-""" -配列の値を書き換える＝＝削除すると同義 -削除する値を一つ決め、それを区切りに右と左の配列に分け、GCDを求める -更に左右のGCDをマージしGCDを求め、最大値が答え -""" -import functools, fractions +from itertools import * +import fractions -L = [0] * (N + 1) -R = [0] * (N + 1) -for i in range(N): -    L[i + 1] = fractions.gcd(L[i], A[i]) -for i in range(N - 1, 0, -1): -    R[i] = fractions.gcd(R[i + 1], A[i]) -ans = 0 -for i in range(N): -    l = L[i] -    r = R[i + 1] -    ans = max(ans, fractions.gcd(l, r)) -print(ans) +L = list(accumulate([0] + A, fractions.gcd)) +R = list(accumulate([0] + A[::-1], fractions.gcd)) +print((max(fractions.gcd(s, t) for s, t in zip(L, R[::-1][1:]))))