#include <bits/stdc++.h>
// using namespace std;
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace edamat {
template <class T>
constexpr auto abs(T i) -> ::std::enable_if_t<::std::is_integral<T>{}(), T> {
    return i < T(0) ? -i : i;
}
template <class M, class N = M>
using common_int_t =
    ::std::enable_if_t<::std::is_integral<M>{}() and ::std::is_integral<N>{}(),
                       ::std::common_type_t<M, N>>;
template <class M, class N>
constexpr common_int_t<M, N> gcd(M m, N n) {
    return n == 0 ? abs(m) : gcd(n, abs(m) % abs(n));
}
template <class M, class N>
constexpr common_int_t<M, N> lcm(M m, N n) {
    return m == 0 or n == 0 ? 0 : (abs(m) / gcd(m, n)) * abs(n);
}
class int_gcd {
   public:
    using value_type = int;
    static value_type operation(value_type x, value_type y) {
        return gcd(x, y);
    };
};

template <class Semigroup>
class disjoint_sparse_table {
   public:
    using value_structure = Semigroup;
    using value_type = typename value_structure::value_type;

   private:
    using container_type = ::std::vector<::std::vector<value_type>>;

   public:
    using const_reference =
        typename container_type::value_type::const_reference;
    using size_type = typename container_type::value_type::size_type;

   protected:
    static size_type msb(size_type c) {
#ifdef __has_builtin
        return 31 - __builtin_clz(c);
#else
        ::std::size_t ret = 0;
        if(c >> 16) c >>= 16, ret += 16;
        if(c >> 8) c >>= 8, ret += 8;
        if(c >> 4) c >>= 4, ret += 4;
        if(c >> 2) c >>= 2, ret += 2;
        return ret + (c >> 1);
#endif
    }

    container_type table;

   public:
    disjoint_sparse_table() : table() {}
    template <class InputIterator>
    disjoint_sparse_table(InputIterator first, InputIterator last) : table() {
        table.emplace_back(first, last);
        const size_type size = table.front().size();
        for(size_type i = 2; i < size; i <<= 1) {
            typename container_type::value_type v;
            v.reserve(size);
            for(size_type j = i; j < size; j += i << 1) {
                v.emplace_back(table.front()[j - 1]);
                for(size_type k = 2; k <= i; ++k)
                    v.emplace_back(value_structure::operation(
                        table.front()[j - k], v.back()));
                v.emplace_back(table.front()[j]);
                for(size_type k = 1; k < i && j + k < size; ++k)
                    v.emplace_back(value_structure::operation(
                        v.back(), table.front()[j + k]));
            }
            table.emplace_back(::std::move(v));
        }
    }

    size_type size() const { return table.empty() ? 0 : table.front().size(); }
    bool empty() const { return size() == 0; }

    value_type fold_closed(const size_type first, const size_type last) const {
        assert(first <= last);
        assert(last < size());
        if(first == last) {
            return table.front()[first];
        } else {
            const size_type p = msb(first ^ last);
            return value_structure::operation(
                table[p][first ^ (static_cast<size_type>(1) << p) - 1],
                table[p][last]);
        }
    }
    value_type fold(const size_type first, const size_type last) const {
        return fold_closed(first, last - 1);
    }
    const_reference operator[](const size_type index) const {
        assert(index < size());
        return table.front()[index];
    }
};
}  // namespace edamat

void ABC125_C() {
    int N;
    scanf("%d", &N);
    std::vector<int> a(N);
    rep(i, N) scanf("%d", &a[i]);
    edamat::disjoint_sparse_table<edamat::int_gcd> data(std::begin(a),
                                                        std::end(a));
    int ans = 0;
    rep(i, N) {
        int left = (i == 0 ? 0 : data.fold(0, i));
        int right = (i == N - 1 ? 0 : data.fold(i + 1, N));
        ans = std::max(ans, edamat::gcd(left, right));
    }
    printf("%d\n", ans);
};

int main() {
    ABC125_C();
    return 0;
};

Measured memory_bytes: 7296