#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)      //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++)    //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/
long long GCD(long long a, long long b){
    return (b ? GCD(b, a%b) : a);
}

/* Segment Tree*/
/*!!!! 0-index !!!! */
template<class T_M>
class SegmentTree {
private:
    int SegSize;
    vector<T_M> Segments;
    const T_M InitValue;
    function<T_M(T_M, T_M)> Func;
    //query
    T_M Q(int p, int q, int node, int l, int r) {
        if(r <= p || q <= l) return InitValue;
        if(p <= l && r <= q) return Segments[node];
        else {
            T_M child1 = Q(p, q, node*2+1, l, (l+r)/2);
            T_M child2 = Q(p, q, node*2+2, (l+r)/2, r);
            return Func(child1, child2);
        }
    }

public:
    //constructor
    SegmentTree(int size, function<T_M(T_M,T_M)> func, T_M InitValue):
        Func(func), InitValue(InitValue) //initialize
    {
        SegSize = 1;
        while(SegSize < size) SegSize <<= 1;
        Segments.assign(SegSize*2-1, InitValue);
    }

    //construct//
    void input(int index, T_M value) {
        Segments[index+SegSize-1] = value;
    }
    void build() { 
        for(int i = SegSize-2; i >= 0; --i) {
            Segments[i] = Func(Segments[i*2+1], Segments[i*2+2]);
        }
    }

    //member funcs//
    void update(int index, T_M value) {
        index += SegSize -1;
        Segments[index] = value;
        while(index != 0) {
            index = (index-1)/2;
            Segments[index] = Func(Segments[index*2+1], Segments[index*2+2]);
        }
    }

    //query for [p, q)
    T_M query(int s, int t) {
        return Q(s, t, 0, 0, SegSize);
    }

    int size() {
        return SegSize;
    }

    T_M operator[] (int index) {
        return Segments[index+SegSize-1];
    }
};
/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);
    
    int n; cin >> n;
    int p = 1;

    SegmentTree<int> seg_gcd(n, [](int a, int b) {return (b ? GCD(b, a%b) : a);}, 0);
    rep(i,n) {
        int num;
        cin >> num;
        seg_gcd.input(i,num);
    }
    seg_gcd.build();
    int maxi = -inf;
    for(int i = 0; i < n; ++i) {
        int num;
        if (i==0) num = seg_gcd.query(1, n);
        else if (i==n-1) num = seg_gcd.query(0, n-1);
        else num = GCD(seg_gcd.query(0,i), seg_gcd.query(i+1, n));
        chmax(maxi, num);
    }
    cout << maxi << endl;
}

Measured memory_bytes: 1280