import fractions

n = int(eval(input()))

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



new_ans = 0

li = [0]*n

li2 = [0]*n



li[0] = a[0]

li2[n-1] = a[n-1]

for i in range(1,n):

    li[i] =fractions.gcd(li[i-1], a[i])



for i in range(1,n)[::-1]:

    li2[i-1] =fractions.gcd(li2[i], a[i-1])



ans =0

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

    tmp = fractions.gcd(li[i-1],li2[i+1])

    if ans < tmp:

        ans = tmp

ans = max(ans, li[n-2], li2[1])

print(ans)

def gcd(a: int, b: int) -> int:

    """a, bの最大公約数(greatest common divisor: GCD)を求める

    計算量: O(log(min(a, b)))

    """

    if b == 0:

        return a

    return gcd(b, a%b)



def ruiseki_lr(array):

    """左右からの畳み込みをそれぞれ計算する

    left[p]  := 区間[0, p)の畳み込み

    right[p] := 区間[p, n)の畳み込み

    """

    op = lambda a, b: gcd(a, b)

    e = 0



    n = len(array)

    left = [e] * (n + 1)

    right = [e] * (n + 1)



    for i in range(n):

        left[i + 1] = op(left[i], array[i])

    for i in reversed(list(range(n))):

        right[i] = op(right[i + 1], array[i])



    return left, right







n = int(eval(input()))

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



left, right = ruiseki_lr(a)

ans = 0

for i in range(n):

    ans = max(gcd(left[i], right[i + 1]), ans)

print(ans)
import fractions

n = int(eval(input()))
a = list(map(int, input().split()))
new_ans = 0
li = [0] * n
li2 = [0] * n
li[0] = a[0]
li2[n - 1] = a[n - 1]
for i in range(1, n):
    li[i] = fractions.gcd(li[i - 1], a[i])
for i in range(1, n)[::-1]:
    li2[i - 1] = fractions.gcd(li2[i], a[i - 1])
ans = 0
for i in range(1, n - 1):
    tmp = fractions.gcd(li[i - 1], li2[i + 1])
    if ans < tmp:
        ans = tmp
ans = max(ans, li[n - 2], li2[1])
print(ans)

def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a % b)


def ruiseki_lr(array):
    """左右からの畳み込みをそれぞれ計算する
    left[p]  := 区間[0, p)の畳み込み
    right[p] := 区間[p, n)の畳み込み
    """
    op = lambda a, b: gcd(a, b)
    e = 0
    n = len(array)
    left = [e] * (n + 1)
    right = [e] * (n + 1)
    for i in range(n):
        left[i + 1] = op(left[i], array[i])
    for i in reversed(list(range(n))):
        right[i] = op(right[i + 1], array[i])
    return left, right


n = int(eval(input()))
a = list(map(int, input().split()))
left, right = ruiseki_lr(a)
ans = 0
for i in range(n):
    ans = max(gcd(left[i], right[i + 1]), ans)
print(ans)

-import fractions +def gcd(a: int, b: int) -> int: +    """a, bの最大公約数(greatest common divisor: GCD)を求める +    計算量: O(log(min(a, b))) +    """ +    if b == 0: +        return a +    return gcd(b, a % b) + + +def ruiseki_lr(array): +    """左右からの畳み込みをそれぞれ計算する +    left[p]  := 区間[0, p)の畳み込み +    right[p] := 区間[p, n)の畳み込み +    """ +    op = lambda a, b: gcd(a, b) +    e = 0 +    n = len(array) +    left = [e] * (n + 1) +    right = [e] * (n + 1) +    for i in range(n): +        left[i + 1] = op(left[i], array[i]) +    for i in reversed(list(range(n))): +        right[i] = op(right[i + 1], array[i]) +    return left, right + -new_ans = 0 -li = [0] * n -li2 = [0] * n -li[0] = a[0] -li2[n - 1] = a[n - 1] -for i in range(1, n): -    li[i] = fractions.gcd(li[i - 1], a[i]) -for i in range(1, n)[::-1]: -    li2[i - 1] = fractions.gcd(li2[i], a[i - 1]) +left, right = ruiseki_lr(a) -for i in range(1, n - 1): -    tmp = fractions.gcd(li[i - 1], li2[i + 1]) -    if ans < tmp: -        ans = tmp -ans = max(ans, li[n - 2], li2[1]) +for i in range(n): +    ans = max(gcd(left[i], right[i + 1]), ans)