#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

template<typename T, typename U>
class SegmentTree{
    int n;
    int height;
    vector<T> node;
    vector<U> lazy;
    vector<int> len;

    using F = function<T(T, T)>;
    using G = function<T(T, U)>;
    using H = function<U(U, U)>;
    using S = function<U(U, int)>;

    F f;
    G g;
    H h;
    S s;
    T en;
    U el;

    void evaluate(int k){
        if(lazy[k] == el){
            return;
        }

        if(k < n){
            lazy[k << 1] = h(lazy[k << 1], lazy[k]);
            lazy[(k << 1) | 1] = h(lazy[(k << 1) | 1], lazy[k]);
        }

        node[k] = g(node[k], s(lazy[k], len[k]));
        lazy[k] = el;

        return;
    }

    void evaluate(int l, int r){
        for(int i = height ; 0 < i ; --i){
            evaluate(l >> i);
            evaluate(r >> i);
        }

        return;
    }

    void update(int k){
        evaluate(k << 1);
        evaluate((k << 1) | 1);
        node[k] = f(node[k << 1], node[(k << 1) | 1]);
        return;
    }

public:
    SegmentTree(int n_, F f_, G g_, H h_, S s_, T en_, U el_){
        init(n_, f_, g_, h_, s_, en_, el_);
    }

    SegmentTree(const vector<T>& dat, F f_, G g_, H h_, S s_, T en_, U el_){
        build(dat, f_, g_, h_, s_, en_, el_);
    }

    void init(int n_, F f_, G g_, H h_, S s_, T en_, U el_){
        n = 1;
        height = 0;
        while(n < n_){
            n <<= 1;
            ++height;
        }
        f = f_;
        g = g_;
        h = h_;
        s = s_;
        en = en_;
        el = el_;

        node.resize(n << 1);
        fill(node.begin(), node.end(), en);
        lazy.resize(n << 1);
        fill(lazy.begin(), lazy.end(), el);

        len.resize(n << 1);
        fill(len.begin(), len.end(), 0);

        for(int i = 0 ; i < n_ ; ++i){
            len[i + n] = 1;
        }

        for(int i = n - 1 ; 0 < i ; --i){
            len[i] = len[i << 1] + len[(i << 1) | 1];
        }

        return;
    }

    void build(const vector<T>& dat, F f_, G g_, H h_, S s_, T en_, U el_){
        int n_ = (int)dat.size();

        init(n_, f_, g_, h_, s_, en_, el_);

        for(int i = 0 ; i < n_ ; ++i){
            node[i + n] = dat[i];
        }

        for(int i = n - 1 ; 0 < i ; --i){
            node[i] = f(node[i << 1], node[(i << 1) | 1]);
        }

        return;
    }

    void update(int l, int r, U x){
        l += n;
        r += n - 1;

        evaluate(l, r);

        int tl = l;
        int tr = r;

        ++r;
        while(l < r){
            if(l & 1){
                lazy[l] = h(lazy[l], x);
                evaluate(l++);
            }
            l >>= 1;
            if(r & 1){
                lazy[--r] = h(lazy[r], x);
                evaluate(r);
            }
            r >>= 1;
        }

        while(tl >>= 1, tr >>= 1, tl){
            if(lazy[tl] == el){
                update(tl);
            }
            if(lazy[tr] == el){
                update(tr);
            }
        }

        return;
    }

    T get(int l, int r){
        l += n;
        r += n - 1;

        evaluate(l, r);

        T res = en;
        ++r;
        while(l < r){
            if(l & 1){
                evaluate(l);
                res = f(res, node[l++]);
            }
            l >>= 1;
            if(r & 1){
                evaluate(--r);
                res = f(res, node[r]);
            }
            r >>= 1;
        }

        return res;
    }
};

template<typename T>
T gcd(T x, T y){
    T r;
    while(y){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

#include<iostream>
#include<climits>

using lint = long long;

int main(){
    int n;
    cin >> n;

    SegmentTree<int, int> seg(n, [](int l, int r){ return gcd(l, r); }, [](int l, int r){ return r; },
    [](int l, int r){ return r; }, [](int l, int r){ return l; }, 0, 0);

    for(int i = 0 ; i < n ; ++i){
        int a;
        cin >> a;
        seg.update(i, i + 1, a);
    }

    int ans = 0;
    for(int i = 0 ; i < n ; ++i){
        ans = max(ans, gcd(seg.get(0, i), seg.get(i + 1, n)));
    }

    // cout << seg.get(0, 0) << " " << seg.get(n, n) << endl;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328