import fractions

import operator

import sys



sys.setrecursionlimit(10000)

INF = float('inf')





class SegmentTree:

    # http://tsutaj.hatenablog.com/entry/2017/03/29/204841

    def __init__(self, size, fn=operator.add, default=0):

        """

        :param int size:

        :param callable fn: 区間に適用する関数。引数を 2 つ取る。min, max, operator.xor など

        """

        # size 以上である最小の 2 冪

        n = 1

        while n < size:

            n *= 2

        self._size = n

        self._tree = [default for _ in range(self._size * 2 - 1)]

        self._fn = fn



    def set(self, i, value):

        """

        i 番目に value を設定

        :param int i:

        :param int value:

        :return:

        """

        x = self._size - 1 + i

        self._tree[x] = value



        while x > 0:

            x = (x - 1) // 2

            self._tree[x] = self._fn(self._tree[x * 2 + 1], self._tree[x * 2 + 2])



    def add(self, i, value):

        """

        もとの i 番目と value に fn を適用したものを i 番目に設定

        :param int i:

        :param int value:

        :return:

        """

        x = self._size - 1 + i

        self.set(i, self._fn(self._tree[x], value))



    def get(self, from_i, to_i, k=0, L=None, r=None):

        """

        [from_i, to_i) に fn を適用した結果を返す

        :param int from_i:

        :param int to_i:

        :param int k: self._tree[k] が、[L, r) に fn を適用した結果を持つ

        :param int L:

        :param int r:

        :return:

        """

        L = 0 if L is None else L

        r = self._size if r is None else r



        if from_i <= L and r <= to_i:

            return self._tree[k]



        if to_i <= L or r <= from_i:

            return None



        ret_L = self.get(from_i, to_i, k * 2 + 1, L, (L + r) // 2)

        ret_r = self.get(from_i, to_i, k * 2 + 2, (L + r) // 2, r)

        if ret_L is None:

            return ret_r

        if ret_r is None:

            return ret_L

        return self._fn(ret_L, ret_r)



    def __len__(self):

        return self._size





N = int(eval(input()))

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



st = SegmentTree(size=N, fn=fractions.gcd, default=0)

for i, a in enumerate(A):

    st.set(i, a)



ans = 0

for i in range(N):

    ans = max(ans, fractions.gcd(st.get(0, i) or 0, st.get(i + 1, N) or 0))

print(ans)

import bisect

import cmath

import heapq

import itertools

import math

import operator

import os

import re

import string

import sys

from collections import Counter, deque, defaultdict

from copy import deepcopy

from decimal import Decimal

from fractions import gcd

from functools import lru_cache, reduce

from operator import itemgetter, mul, add, xor



import numpy as np



if os.getenv("LOCAL"):

    sys.stdin = open("_in.txt", "r")



sys.setrecursionlimit(10 ** 9)

INF = float("inf")

IINF = 10 ** 18

MOD = 10 ** 9 + 7

# MOD = 998244353



N = int(sys.stdin.buffer.readline())

A = list(map(int, sys.stdin.buffer.readline().split()))



# 1個の変える先は他のやつの最大公約数にすればいいので、

# N-1個の最大公約数の最大値を求める

lefts = list(itertools.accumulate(A, gcd))

rights = list(itertools.accumulate(A[::-1], gcd))[::-1]



ans = 0

for i in range(N):

    if i == 0:

        ans = max(ans, rights[1])

    elif i == N - 1:

        ans = max(ans, lefts[-2])

    else:

        ans = max(ans, gcd(lefts[i - 1], rights[i + 1]))

print(ans)

import fractions
import operator
import sys

sys.setrecursionlimit(10000)
INF = float("inf")


class SegmentTree:
    # http://tsutaj.hatenablog.com/entry/2017/03/29/204841
    def __init__(self, size, fn=operator.add, default=0):
        """
        :param int size:
        :param callable fn: 区間に適用する関数。引数を 2 つ取る。min, max, operator.xor など
        """
        # size 以上である最小の 2 冪
        n = 1
        while n < size:
            n *= 2
        self._size = n
        self._tree = [default for _ in range(self._size * 2 - 1)]
        self._fn = fn

    def set(self, i, value):
        """
        i 番目に value を設定
        :param int i:
        :param int value:
        :return:
        """
        x = self._size - 1 + i
        self._tree[x] = value
        while x > 0:
            x = (x - 1) // 2
            self._tree[x] = self._fn(self._tree[x * 2 + 1], self._tree[x * 2 + 2])

    def add(self, i, value):
        """
        もとの i 番目と value に fn を適用したものを i 番目に設定
        :param int i:
        :param int value:
        :return:
        """
        x = self._size - 1 + i
        self.set(i, self._fn(self._tree[x], value))

    def get(self, from_i, to_i, k=0, L=None, r=None):
        """
        [from_i, to_i) に fn を適用した結果を返す
        :param int from_i:
        :param int to_i:
        :param int k: self._tree[k] が、[L, r) に fn を適用した結果を持つ
        :param int L:
        :param int r:
        :return:
        """
        L = 0 if L is None else L
        r = self._size if r is None else r
        if from_i <= L and r <= to_i:
            return self._tree[k]
        if to_i <= L or r <= from_i:
            return None
        ret_L = self.get(from_i, to_i, k * 2 + 1, L, (L + r) // 2)
        ret_r = self.get(from_i, to_i, k * 2 + 2, (L + r) // 2, r)
        if ret_L is None:
            return ret_r
        if ret_r is None:
            return ret_L
        return self._fn(ret_L, ret_r)

    def __len__(self):
        return self._size


N = int(eval(input()))
A = list(map(int, input().split()))
st = SegmentTree(size=N, fn=fractions.gcd, default=0)
for i, a in enumerate(A):
    st.set(i, a)
ans = 0
for i in range(N):
    ans = max(ans, fractions.gcd(st.get(0, i) or 0, st.get(i + 1, N) or 0))
print(ans)

import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor
import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10**9)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7
# MOD = 998244353
N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))
# 1個の変える先は他のやつの最大公約数にすればいいので、
# N-1個の最大公約数の最大値を求める
lefts = list(itertools.accumulate(A, gcd))
rights = list(itertools.accumulate(A[::-1], gcd))[::-1]
ans = 0
for i in range(N):
    if i == 0:
        ans = max(ans, rights[1])
    elif i == N - 1:
        ans = max(ans, lefts[-2])
    else:
        ans = max(ans, gcd(lefts[i - 1], rights[i + 1]))
print(ans)

-import fractions +import bisect +import cmath +import heapq +import itertools +import math +import os +import re +import string +from collections import Counter, deque, defaultdict +from copy import deepcopy +from decimal import Decimal +from fractions import gcd +from functools import lru_cache, reduce +from operator import itemgetter, mul, add, xor +import numpy as np -sys.setrecursionlimit(10000) +if os.getenv("LOCAL"): +    sys.stdin = open("_in.txt", "r") +sys.setrecursionlimit(10**9) - - -class SegmentTree: -    # http://tsutaj.hatenablog.com/entry/2017/03/29/204841 -    def __init__(self, size, fn=operator.add, default=0): -        """ -        :param int size: -        :param callable fn: 区間に適用する関数。引数を 2 つ取る。min, max, operator.xor など -        """ -        # size 以上である最小の 2 冪 -        n = 1 -        while n < size: -            n *= 2 -        self._size = n -        self._tree = [default for _ in range(self._size * 2 - 1)] -        self._fn = fn - -    def set(self, i, value): -        """ -        i 番目に value を設定 -        :param int i: -        :param int value: -        :return: -        """ -        x = self._size - 1 + i -        self._tree[x] = value -        while x > 0: -            x = (x - 1) // 2 -            self._tree[x] = self._fn(self._tree[x * 2 + 1], self._tree[x * 2 + 2]) - -    def add(self, i, value): -        """ -        もとの i 番目と value に fn を適用したものを i 番目に設定 -        :param int i: -        :param int value: -        :return: -        """ -        x = self._size - 1 + i -        self.set(i, self._fn(self._tree[x], value)) - -    def get(self, from_i, to_i, k=0, L=None, r=None): -        """ -        [from_i, to_i) に fn を適用した結果を返す -        :param int from_i: -        :param int to_i: -        :param int k: self._tree[k] が、[L, r) に fn を適用した結果を持つ -        :param int L: -        :param int r: -        :return: -        """ -        L = 0 if L is None else L -        r = self._size if r is None else r -        if from_i <= L and r <= to_i: -            return self._tree[k] -        if to_i <= L or r <= from_i: -            return None -        ret_L = self.get(from_i, to_i, k * 2 + 1, L, (L + r) // 2) -        ret_r = self.get(from_i, to_i, k * 2 + 2, (L + r) // 2, r) -        if ret_L is None: -            return ret_r -        if ret_r is None: -            return ret_L -        return self._fn(ret_L, ret_r) - -    def __len__(self): -        return self._size - - -N = int(eval(input())) -A = list(map(int, input().split())) -st = SegmentTree(size=N, fn=fractions.gcd, default=0) -for i, a in enumerate(A): -    st.set(i, a) +IINF = 10**18 +MOD = 10**9 + 7 +# MOD = 998244353 +N = int(sys.stdin.buffer.readline()) +A = list(map(int, sys.stdin.buffer.readline().split())) +# 1個の変える先は他のやつの最大公約数にすればいいので、 +# N-1個の最大公約数の最大値を求める +lefts = list(itertools.accumulate(A, gcd)) +rights = list(itertools.accumulate(A[::-1], gcd))[::-1] -    ans = max(ans, fractions.gcd(st.get(0, i) or 0, st.get(i + 1, N) or 0)) +    if i == 0: +        ans = max(ans, rights[1]) +    elif i == N - 1: +        ans = max(ans, lefts[-2]) +    else: +        ans = max(ans, gcd(lefts[i - 1], rights[i + 1]))