from fractions import gcd





class SegmentTree():

    _data = []

    _offset = 0

    _size = 0



    def __init__(self, size):

        _size = size

        t = 1

        while t <= size:

            t *= 2

        self._offset = t - 1

        self._data = [0] * (t * 2 - 1)



    def update_all(self, iterable):

        self._data[self._offset:self._offset+self._size] = iterable

        for i in range(self._offset - 1, -1, -1):

            self._data[i] = gcd(self._data[i * 2 + 1], self._data[i * 2 + 2])



    def update(self, index, value):

        i = self._offset + index

        self._data[i] = value

        while i >= 1:

            i = (i - 1) // 2

            self._data[i] = gcd(self._data[i * 2 + 1], self._data[i * 2 + 2])



    def query(self, start, stop):

        result = 0

        l = start + self._offset

        r = stop + self._offset

        while l < r:

            if l & 1 == 0:

                result = gcd(result, self._data[l])

            if r & 1 == 0:

                result = gcd(result, self._data[r - 1])

            l = l // 2

            r = (r - 1) // 2

        return result



N = int(eval(input()))

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



st = SegmentTree(N)

st.update_all(A)



result = st.query(1, N)

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

    result = max(result, gcd(st.query(0, i), st.query(i + 1, N)))

result = max(result, st.query(0, N - 1))

print(result)

# Sparse table (GCD)

from math import gcd





class SparseTable():

    _data = None

    _lookup = None

    _f = None



    def __init__(self, a):

        data = []

        lookup = []

        f = gcd

        b = 0

        while (1 << b) <= len(a):

            b += 1

        for _ in range(b):

            data.append([0] * (1 << b))

        data[0][:len(a)] = a

        for i in range(1, b):

            j = 0

            di = data[i]

            di1 = data[i - 1]

            while j + (1 << i) <= (1 << b):

                di[j] = f(di1[j], di1[j + (1 << (i - 1))])

                j += 1

        lookup = [0] * (len(a) + 1)

        for i in range(2, len(lookup)):

            lookup[i] = lookup[i >> 1] + 1

        self._data = data

        self._lookup = lookup

        self._f = f



    def query(self, start, stop):

        b = self._lookup[stop - start]

        db = self._data[b]

        return self._f(db[start], db[stop - (1 << b)])





N = int(eval(input()))

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



st = SparseTable(A)



result = st.query(1, N)

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

    result = max(result, gcd(st.query(0, i), st.query(i + 1, N)))

result = max(result, st.query(0, N - 1))

print(result)

from fractions import gcd


class SegmentTree:
    _data = []
    _offset = 0
    _size = 0

    def __init__(self, size):
        _size = size
        t = 1
        while t <= size:
            t *= 2
        self._offset = t - 1
        self._data = [0] * (t * 2 - 1)

    def update_all(self, iterable):
        self._data[self._offset : self._offset + self._size] = iterable
        for i in range(self._offset - 1, -1, -1):
            self._data[i] = gcd(self._data[i * 2 + 1], self._data[i * 2 + 2])

    def update(self, index, value):
        i = self._offset + index
        self._data[i] = value
        while i >= 1:
            i = (i - 1) // 2
            self._data[i] = gcd(self._data[i * 2 + 1], self._data[i * 2 + 2])

    def query(self, start, stop):
        result = 0
        l = start + self._offset
        r = stop + self._offset
        while l < r:
            if l & 1 == 0:
                result = gcd(result, self._data[l])
            if r & 1 == 0:
                result = gcd(result, self._data[r - 1])
            l = l // 2
            r = (r - 1) // 2
        return result


N = int(eval(input()))
A = list(map(int, input().split()))
st = SegmentTree(N)
st.update_all(A)
result = st.query(1, N)
for i in range(1, N - 1):
    result = max(result, gcd(st.query(0, i), st.query(i + 1, N)))
result = max(result, st.query(0, N - 1))
print(result)

# Sparse table (GCD)
from math import gcd


class SparseTable:
    _data = None
    _lookup = None
    _f = None

    def __init__(self, a):
        data = []
        lookup = []
        f = gcd
        b = 0
        while (1 << b) <= len(a):
            b += 1
        for _ in range(b):
            data.append([0] * (1 << b))
        data[0][: len(a)] = a
        for i in range(1, b):
            j = 0
            di = data[i]
            di1 = data[i - 1]
            while j + (1 << i) <= (1 << b):
                di[j] = f(di1[j], di1[j + (1 << (i - 1))])
                j += 1
        lookup = [0] * (len(a) + 1)
        for i in range(2, len(lookup)):
            lookup[i] = lookup[i >> 1] + 1
        self._data = data
        self._lookup = lookup
        self._f = f

    def query(self, start, stop):
        b = self._lookup[stop - start]
        db = self._data[b]
        return self._f(db[start], db[stop - (1 << b)])


N = int(eval(input()))
A = list(map(int, input().split()))
st = SparseTable(A)
result = st.query(1, N)
for i in range(1, N - 1):
    result = max(result, gcd(st.query(0, i), st.query(i + 1, N)))
result = max(result, st.query(0, N - 1))
print(result)

-from fractions import gcd +# Sparse table (GCD) +from math import gcd -class SegmentTree: -    _data = [] -    _offset = 0 -    _size = 0 +class SparseTable: +    _data = None +    _lookup = None +    _f = None -    def __init__(self, size): -        _size = size -        t = 1 -        while t <= size: -            t *= 2 -        self._offset = t - 1 -        self._data = [0] * (t * 2 - 1) - -    def update_all(self, iterable): -        self._data[self._offset : self._offset + self._size] = iterable -        for i in range(self._offset - 1, -1, -1): -            self._data[i] = gcd(self._data[i * 2 + 1], self._data[i * 2 + 2]) - -    def update(self, index, value): -        i = self._offset + index -        self._data[i] = value -        while i >= 1: -            i = (i - 1) // 2 -            self._data[i] = gcd(self._data[i * 2 + 1], self._data[i * 2 + 2]) +    def __init__(self, a): +        data = [] +        lookup = [] +        f = gcd +        b = 0 +        while (1 << b) <= len(a): +            b += 1 +        for _ in range(b): +            data.append([0] * (1 << b)) +        data[0][: len(a)] = a +        for i in range(1, b): +            j = 0 +            di = data[i] +            di1 = data[i - 1] +            while j + (1 << i) <= (1 << b): +                di[j] = f(di1[j], di1[j + (1 << (i - 1))]) +                j += 1 +        lookup = [0] * (len(a) + 1) +        for i in range(2, len(lookup)): +            lookup[i] = lookup[i >> 1] + 1 +        self._data = data +        self._lookup = lookup +        self._f = f -        result = 0 -        l = start + self._offset -        r = stop + self._offset -        while l < r: -            if l & 1 == 0: -                result = gcd(result, self._data[l]) -            if r & 1 == 0: -                result = gcd(result, self._data[r - 1]) -            l = l // 2 -            r = (r - 1) // 2 -        return result +        b = self._lookup[stop - start] +        db = self._data[b] +        return self._f(db[start], db[stop - (1 << b)]) -st = SegmentTree(N) -st.update_all(A) +st = SparseTable(A)