//#pragma GCC optimize ("O3","unroll-loops")
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cassert>

#include<cmath>
#include<functional>
#include<algorithm>
#include<numeric>

#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<bitset>
#include<tuple>

#define TEST {IS_TEST=true;}
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mpp(x,y,z) make_pair(make_pair(x,y),z)

using namespace std;
using ll = int_fast64_t;
using v_b = vector <bool>; using v_ll = vector <ll>; using str = string; using v_str = vector <string>; using p_ll = pair < ll,ll >;
using vv_b = vector < v_b >; using vv_ll = vector < v_ll >; using vp_ll = vector < p_ll >;
using vvv_ll = vector < vv_ll >; using vvp_ll = vector < vp_ll >;
using ld = long double; using v_ld = vector <ld>; using vv_ld = vector<v_ld>;

bool IS_TEST=false;
ll ll_min64=1LL<<63;
ll ll_max64=~ll_min64;
ll ll_min32=1LL<<31;
ll ll_max32=~ll_min32;

ll MOD = 1000000007;

/*displaying functions for debug*/
template<class T> void show2(const T &x){cerr << x;}
template<class T1,class T2> void show2(const pair<T1,T2> &x){
  cerr << "{" << show2(x.first) << "," << show2(x.second) << "}";
}
template<class T> void show(const T &x){
  if (!IS_TEST) return; show2(x); cerr << "\n";
}
template<class T> void v_show(const T &v, ll n=-1){
  if (!IS_TEST) return; auto itr=v.begin(); ll m=n;
  while(itr!=v.end() && m!=0 ){ show2(*itr); cerr << " "; itr++; m--;}
  cerr << "\n";
}
template<class T> void vv_show(const T &v, ll n=-1){
  if (!IS_TEST) return;
  cerr << "--------------------------------\n";
  auto itr=v.begin(); ll m=n;
  while(itr!=v.end() && m!=0 ){ cerr << n-m << ": \t"; v_show(*itr,n); itr++; m--;}
  cerr << "--------------------------------\n";
}
/*--------------------------------*/

/*loading integers*/
void load(ll& x1){ cin >> x1; }
void load(ll& x1,ll& x2){ cin >> x1 >> x2; }
void load(ll& x1,ll& x2,ll& x3){ cin >> x1 >> x2 >> x3; }
void load(ll& x1,ll& x2,ll& x3,ll& x4){ cin >> x1 >> x2 >> x3 >> x4; }
void v_load(ll n, v_ll& v1, ll head=0, ll tail=0, ll init=0){
    ll m=n+head+tail; v1.assign(m,init);
    for (ll i=0;i<n;i++){ scanf("%lld",&v1[i+head]); }
}
void v_load(ll n, v_ll& v1 ,v_ll& v2, ll head=0, ll tail=0, ll init=0){
    ll m=n+head+tail; v1.assign(m,init); v2.assign(m,init);
    for (ll i=0;i<n;i++){ scanf("%lld%lld",&v1[i+head],&v2[i+head]); }
}
void v_load(ll n, v_ll& v1 ,v_ll& v2, v_ll& v3, ll head=0, ll tail=0, ll init=0){
    ll m=n+head+tail; v1.assign(m,init); v2.assign(m,init); v3.assign(m,init);
    for (ll i=0;i<n;i++){ scanf("%lld%lld%lld",&v1[i+head],&v2[i+head],&v3[i+head]); }
}
void v_load(ll n, v_ll& v1 ,v_ll& v2, v_ll& v3, v_ll& v4, ll head=0, ll tail=0, ll init=0){
    ll m=n+head+tail; v1.assign(m,init); v2.assign(m,init); v3.assign(m,init); v4.assign(m,init);
    for (ll i=0;i<n;i++){ scanf("%lld%lld%lld%lld",&v1[i+head],&v2[i+head],&v3[i+head],&v4[i+head]); }
}
/*--------------------------------*/

/*output*/
template <class T>void put(T x){cout << x << "\n";}
template <class T1,class T2>void put(T1 x,T2 y){cout << x << " " << y << "\n";}
/*---*/

v_ll local_sort(ll x1=ll_max64, ll x2=ll_max64, ll x3=ll_max64, ll x4=ll_max64){
    v_ll x{x1,x2,x3,x4};
    sort(x.begin(),x.end());
    return x;
}

ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x<y?x:y;}

ll max(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) {ans=max(ans,*b);b++;}
    return ans;
}
ll argmax(v_ll::iterator b,v_ll::iterator e){
    ll ans=0, cnt=0, val=*b;
    while (b<e) { if (val<*b) {ans=cnt; val=*b;} cnt++; b++;}
    return ans;
}
ll min(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) {ans=min(ans,*b);b++;}
    return ans;
}
ll argmin(v_ll::iterator b,v_ll::iterator e){
    ll ans=0, cnt=0, val=*b;
    while (b<e) { if (val>*b) {ans=cnt; val=*b;} cnt++; b++;}
    return ans;
}
ll sum(v_ll::iterator b,v_ll::iterator e){
    ll ans=0;
    while (b<e) {ans+=*b;b++;}
    return ans;
}

template<class T> bool chmax(T& x,const T& y){ if (x>=y) return false; x=y; return true;}
template<class T> bool chmin(T& x,const T& y){ if (x<=y) return false; x=y; return true;}

template<class T> void quit(T x){cout << x << endl; exit(0);}
void yesno(bool x){cout << (x?"Yes":"No") <<endl;}

ll roundup(ll x,ll y){return (x-1)/y+1;}
ll rem(ll x,ll y){ ll z=x%y; return z>=0?z:z+y; }



template<typename T>
struct SegTree{
    ll size; vector<T> tree;
    void init(ll n){
        size=1; while(size<n)size*=2;
        tree=vector<T>(size*2,unit());
    }
    void init(const vector<T>& v){
        size=1; while(size<v.size()) size*=2;
        tree=vector<T>(size*2,unit());
        for(ll i=size;i<size+v.size();++i)tree[i]=v[i-size];
        for(ll i=size-1;i>=0;--i)tree[i]=merge(tree[i*2],tree[i*2+1]);
    }
    void show(){
        ll x=2;
        for(ll i=1;i<size*2;++i){
            cerr << tree[i];
            if(i+1==x){x*=2; cerr<<"\n";} else  cerr<< " ";
        }
    }
    void update(ll x, T t){
        x+=size; tree[x]=t;
        while (x>=2){ x>>=1; tree[x]=merge(tree[x*2],tree[x*2+1]);}
    }
    T query(ll x){
        if (x<0||x>=size) return unit();
        return tree[size+x];
    }
    T query(ll l, ll r){
        if (r<0||l>=size||r<l) return unit();
        if (r>=size) r=size-1;
        if (l<0) l=0;
        T t=unit(); ll rank=0;
        for(; l+(1LL<<rank)-1<=r; ++rank){
            if (l&(1LL<<rank)) {
                t=merge(t,tree[(l+size)>>rank]);
                l+=(1LL<<rank);
            }
        }
        for(; rank>=0; --rank){
            if (l+(1LL<<rank)-1<=r) {
                t=merge(t,tree[(l+size)>>rank]);
                l+=(1LL<<rank);
            }
        }
        return t;
    }
    virtual T unit(){return T();}
    virtual T merge(const T& l,const T& r){ return l+r;}
};

struct RminQ: public SegTree<ll>{
    virtual ll unit(){return 100000000LL;}
    virtual ll merge(const ll& l,const ll& r){ return min(l,r);}
};

struct RmaxQ: public SegTree<ll>{
    virtual ll unit(){return -100000000LL;}
    virtual ll merge(const ll& l,const ll& r){ return max(l,r);}
};

ll gcd(ll x, ll y){
    while (y>0){
        x%=y;
        swap(x,y);
    }
    return x;
}

struct RgcdQ: public SegTree<ll>{
    virtual ll unit(){return 0;}
    virtual ll merge(const ll& l,const ll& r){ return gcd(l,r);}
};

int main(){
    ll N;
    cin >> N;
    v_ll A(N);
    for(ll i=0;i<N;i++){
        cin >>A[i];
    }
    RgcdQ s; s.init(A);
    ll ans=0LL;
    for(ll i=0;i<N;i++){
        chmax(ans,gcd(s.query(0,i-1),s.query(i+1,N-1)));
    }
    cout << ans << "\n";
}




Measured memory_bytes: 3072