#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7;
constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

template<class T>T gcd(T a, T b) { if (a > b) swap(a, b); return a ? gcd(a, b % a) : b; }

template <typename T>
struct SegmentTree {
    using F = function<T(T, T)>;
    int n; // (要素数nが収まる2^k) * 2 - 1
    F f; // 扱う二項演算(モノイド)
    T ti; // 単位元
    vector<T> dat;

    SegmentTree() {};
    SegmentTree(F f, T ti) :f(f), ti(ti) {}
    void init(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        dat.assign(n << 1, ti);
    }
    void build(const vector<T>& v) {
        int n_ = v.size();
        init(n_);
        for (int i = 0; i < n_; i++) dat[n + i] = v[i]; // 生要素は後半
        for (int i = n - 1; i; i--) dat[i] = f(dat[i * 2], dat[i * 2 + 1]); // 部分演算結果が前半
    }
    void update(int k, T x) {
        dat[k += n] = x;
        while (k /= 2) dat[k] = f(dat[k * 2], dat[k * 2 + 1]);
    }
    T query(int a, int b) {
        T vl = ti, vr = ti;
        for (int l = a + n, r = b + n; l < r; l /= 2, r /= 2) {
            if (l & 1) vl = f(vl, dat[l++]);
            if (r & 1) vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }
    // んにゃぴ
    template<typename C>
    int find(int a, int b, C & check, int k, int l, int r) {
        if (!check(dat[k]) || r <= a || b <= l) return -1;
        if (k >= n) return k - n;
        int m = (l + r) >> 1;
        int vl = find(a, b, check, (k << 1) | 0, l, m);
        if (~vl) return vl;
        return find(a, b, check, (k << 1) | 1, m, r);
    }
    template<typename C>
    int find(int a, int b, C & check) {
        return find(a, b, check, 1, 0, n);
    }

    void test() {
        auto f = [](int a, int b) {return min(a, b); };
        SegmentTree<int> st(f, INF);
        vector<int> v;
        st.build(v);
    }
};

int N;
vi A;
vi B;

int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    auto f = [](int a, int b) { return a == 0 ? b : b == 0 ? a : gcd(a, b); };
    SegmentTree<int> st(f, 0);
    st.build(A);

    int ans = 0;

    rep(i, N) {
        int gcd_l = 0;
        if (i != 0) gcd_l = st.query(0, i);
        int gcd_h = 0;
        if (i != N - 1) gcd_h = st.query(i + 1, N);
        
        if (i != 0) {
            if (i != N - 1) {
                chmax(ans, gcd(gcd_l, gcd_h));
            }
            else {
                chmax(ans, gcd_l);
            }
        }
        else if (i != N - 1) {
            chmax(ans, gcd_h);
        }
    }

    //int l = 0;
    //int h = N;
    //int ans = INF;
    //for (;h - l > 1;) {
    //    int mid = (l + h) / 2;
    //    
    //    int gcd_l = A[l];
    //    rep(i, l, mid) {
    //        gcd_l = gcd(gcd_l, A[i]);
    //    }

    //    int gcd_h = A[mid];
    //    rep(i, mid, h) {
    //        gcd_h = gcd(gcd_h, A[i]);
    //    }

    //    if (gcd_l < gcd_h) {
    //        ans = gcd(ans, gcd_h);
    //        h = mid;
    //    }
    //    else if (gcd_l > gcd_h) {
    //        ans = gcd(ans, gcd_l);
    //        l = mid;
    //    }
    //    else {
    //        ans = gcd_h;
    //        break;
    //    }

    //    if (h - l < 2) break;
    //}

    write(ans);
}

Measured memory_bytes: 1664