from operator import itemgetter

from functools import reduce

import fractions as f

import sys

input = sys.stdin.readline



n = int(eval(input()))

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

rev_a = list(reversed(a))

ans = 0

accumulation_gcd = [0] * n

rev_accumulation_gcd = [0] * n

accumulation_gcd[0] = a[0]

rev_accumulation_gcd[0] = rev_a[0]



for i in range(1, n):

    accumulation_gcd[i] = f.gcd(a[i], accumulation_gcd[i-1])

    rev_accumulation_gcd[i] = f.gcd(rev_a[i], rev_accumulation_gcd[i-1])



rev_accumulation_gcd.reverse()





for i in range(n):

    if i == 0:

        ans = max(ans, rev_accumulation_gcd[1])

    elif i == (n - 1):

        ans = max(ans, accumulation_gcd[n-2])

    else:

        ans = max(ans, f.gcd(accumulation_gcd[i-1], rev_accumulation_gcd[i+1]))



print(ans)

import fractions

n = int(eval(input()))

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



gcd_from_left = [a[0]]

gcd_from_right = [a[-1]]



for i in range(1, n):

    gcd_from_left.append(fractions.gcd(gcd_from_left[i - 1], a[i]))

    gcd_from_right.append(fractions.gcd(gcd_from_right[i - 1], a[n - 1 - i]))



gcd_from_right.reverse()



ans = 0

for i in range(n):

    if i == 0:

        ans = max(ans, gcd_from_right[1])

    elif i == n - 1:

        ans = max(ans, gcd_from_left[n - 2])

    else:

        ans = max(ans, fractions.gcd(gcd_from_left[i - 1], gcd_from_right[i + 1]))

print(ans)

from operator import itemgetter
from functools import reduce
import fractions as f
import sys

input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
rev_a = list(reversed(a))
ans = 0
accumulation_gcd = [0] * n
rev_accumulation_gcd = [0] * n
accumulation_gcd[0] = a[0]
rev_accumulation_gcd[0] = rev_a[0]
for i in range(1, n):
    accumulation_gcd[i] = f.gcd(a[i], accumulation_gcd[i - 1])
    rev_accumulation_gcd[i] = f.gcd(rev_a[i], rev_accumulation_gcd[i - 1])
rev_accumulation_gcd.reverse()
for i in range(n):
    if i == 0:
        ans = max(ans, rev_accumulation_gcd[1])
    elif i == (n - 1):
        ans = max(ans, accumulation_gcd[n - 2])
    else:
        ans = max(ans, f.gcd(accumulation_gcd[i - 1], rev_accumulation_gcd[i + 1]))
print(ans)

import fractions

n = int(eval(input()))
a = list(map(int, input().split()))
gcd_from_left = [a[0]]
gcd_from_right = [a[-1]]
for i in range(1, n):
    gcd_from_left.append(fractions.gcd(gcd_from_left[i - 1], a[i]))
    gcd_from_right.append(fractions.gcd(gcd_from_right[i - 1], a[n - 1 - i]))
gcd_from_right.reverse()
ans = 0
for i in range(n):
    if i == 0:
        ans = max(ans, gcd_from_right[1])
    elif i == n - 1:
        ans = max(ans, gcd_from_left[n - 2])
    else:
        ans = max(ans, fractions.gcd(gcd_from_left[i - 1], gcd_from_right[i + 1]))
print(ans)

-from operator import itemgetter -from functools import reduce -import fractions as f -import sys +import fractions -input = sys.stdin.readline -rev_a = list(reversed(a)) +gcd_from_left = [a[0]] +gcd_from_right = [a[-1]] +for i in range(1, n): +    gcd_from_left.append(fractions.gcd(gcd_from_left[i - 1], a[i])) +    gcd_from_right.append(fractions.gcd(gcd_from_right[i - 1], a[n - 1 - i])) +gcd_from_right.reverse() -accumulation_gcd = [0] * n -rev_accumulation_gcd = [0] * n -accumulation_gcd[0] = a[0] -rev_accumulation_gcd[0] = rev_a[0] -for i in range(1, n): -    accumulation_gcd[i] = f.gcd(a[i], accumulation_gcd[i - 1]) -    rev_accumulation_gcd[i] = f.gcd(rev_a[i], rev_accumulation_gcd[i - 1]) -rev_accumulation_gcd.reverse() -        ans = max(ans, rev_accumulation_gcd[1]) -    elif i == (n - 1): -        ans = max(ans, accumulation_gcd[n - 2]) +        ans = max(ans, gcd_from_right[1]) +    elif i == n - 1: +        ans = max(ans, gcd_from_left[n - 2]) -        ans = max(ans, f.gcd(accumulation_gcd[i - 1], rev_accumulation_gcd[i + 1])) +        ans = max(ans, fractions.gcd(gcd_from_left[i - 1], gcd_from_right[i + 1]))