import fractions

N = int(eval(input()))

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

right = [A[0]]*N

left = [A[-1]]*N

for i in range(1,N):

    right[i] = fractions.gcd(right[i-1],A[i])

    left[N-1-i] = fractions.gcd(left[N-i],A[N-1-i])

ans = left[1]

for i in range(N-2):

    ans = max(ans,fractions.gcd(right[i],left[i+2]))

print((max(ans,right[N-2])))

import math

N = int(eval(input()))

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

gcd_right = [arr[0]]

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

    gcd_right.append(math.gcd(gcd_right[i-1],arr[i]))

arr = arr[::-1]

gcd_left = [arr[0]]

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

    gcd_left.append(math.gcd(gcd_left[i-1],arr[i]))

gcd_left = gcd_left[::-1]

ans = max(gcd_right[-1],gcd_left[0])

for i in range(N-2):

    ans = max(ans,math.gcd(gcd_left[i+1],gcd_right[i]))

print(ans)
import fractions

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

import math

N = int(eval(input()))
arr = list(map(int, input().split()))
gcd_right = [arr[0]]
for i in range(1, N - 1):
    gcd_right.append(math.gcd(gcd_right[i - 1], arr[i]))
arr = arr[::-1]
gcd_left = [arr[0]]
for i in range(1, N - 1):
    gcd_left.append(math.gcd(gcd_left[i - 1], arr[i]))
gcd_left = gcd_left[::-1]
ans = max(gcd_right[-1], gcd_left[0])
for i in range(N - 2):
    ans = max(ans, math.gcd(gcd_left[i + 1], gcd_right[i]))
print(ans)

-import fractions +import math -A = list(map(int, input().split())) -right = [A[0]] * N -left = [A[-1]] * N -for i in range(1, N): -    right[i] = fractions.gcd(right[i - 1], A[i]) -    left[N - 1 - i] = fractions.gcd(left[N - i], A[N - 1 - i]) -ans = left[1] +arr = list(map(int, input().split())) +gcd_right = [arr[0]] +for i in range(1, N - 1): +    gcd_right.append(math.gcd(gcd_right[i - 1], arr[i])) +arr = arr[::-1] +gcd_left = [arr[0]] +for i in range(1, N - 1): +    gcd_left.append(math.gcd(gcd_left[i - 1], arr[i])) +gcd_left = gcd_left[::-1] +ans = max(gcd_right[-1], gcd_left[0]) -    ans = max(ans, fractions.gcd(right[i], left[i + 2])) -print((max(ans, right[N - 2]))) +    ans = max(ans, math.gcd(gcd_left[i + 1], gcd_right[i])) +print(ans)