#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define es cout<<" "
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;
template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts> 
auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

/****************** 数論 ******************/
// 最大公約数
lint gcd(lint a, lint b) {
    // 引数の一方が 0 なら他方の値を返す
    return b ? gcd(b, a%b) : a;
}

/****************** データ構造 ******************/
// セグメントツリー (点変更・区間クエリ)
template <typename monoid>
struct segment_tree {
    using M = monoid;
    using T = typename M::value_type;

    size_t sz;
    vector<T> x;

    segment_tree(size_t n = 0) {
        sz = 1;
        while (sz < n) sz *= 2;
        x.assign(sz * 2, M::id());
        initialize();
    }

    template <typename iterator>
    segment_tree(iterator first, iterator last) {
        sz = 1;
        size_t n = distance(first, last);
        while (sz < n) sz *= 2;
        x.assign(sz * 2, M::id());
        copy(first, last, x.begin() + sz);
        initialize();
    }

    void fill(const T& val) {
        std::fill(x.begin() + sz, x.end(), val);
        initialize();
    }

    void initialize() {
        for (int i = (int)sz - 1; i >= 1; --i) {
            x[i] = M::op(x[i * 2 + 0], x[i * 2 + 1]);
        }
    }

    T accumulate(size_t l, size_t r) const {  // [l, r)
        T al = M::id(), ar = M::id();
        for (l += sz, r += sz; l < r; l /= 2, r /= 2) {
            if (l & 1) al = M::op(al, x[l++]);
            if (r & 1) ar = M::op(x[--r], ar);
        }
        return M::op(al, ar);
    }

    void update(size_t i, const T &val) {
        x[i += sz] = val;
        while (i > 1) {
            x[i / 2] = M::op(x[i], x[i ^ 1]);
            i /= 2;
        }
    }

    T operator[](size_t i) const { return x[sz + i]; }
};

template <typename T>
struct gcd_monoid {
    using value_type = T;
    static constexpr T id() { return 0; }
    static T op(const T &a, const T &b) { return gcd(a, b); }
};

template <typename value_type>
using rgq = segment_tree<gcd_monoid<value_type>>;

int main(void) {
    int n; cin >> n;
    vector<int> v(n); repeat (i, n) cin >> v[i];
    rgq<int> segtree(n);
    repeat (i, n) segtree.update(i, v[i]);
    
    int ans = 0;
    repeat (i, n) {
        segtree.update(i, 0);
        ans = max(ans, segtree.accumulate(0, n));
        segtree.update(i, v[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1664