#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

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

vector<int> pro(int k){
    vector<int> res;
    while(k>0){
        res.push_back(k%2);
        k/=2;
    }
    reverse(all(res));
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    REP(i,n){
        cin >> a[i];
        b[i] = a[i];
    }
    reverse(all(b));
    int dep = 0;
    int t = 1;
    while(n>=t){
        t*=2;
        dep++;
    }
    vector<vector<int>> d1(dep);
    REP(i,n){
        d1[0].push_back(a[i]);
    }
    REP(i,dep-1){
        REP(j,d1[i].size()/2){
            if(j*2+1<d1[i].size()){
                //int k = pow(2,i);
                int temp = gcd(d1[i][j*2],d1[i][j*2+1]);
                d1[i+1].push_back(temp);
            }
        }
    }
    vector<vector<int>> d2(dep);
    REP(i,n){
        d2[0].push_back(b[i]);
    }
    REP(i,dep-1){
        REP(j,d2[i].size()/2){
            if(j*2+1<d2[i].size()){
                //int k= pow(2,i);
                int temp = gcd(d2[i][j*2],d2[i][j*2+1]);
                d2[i+1].push_back(temp);
            }
        }
    }
    int res = 0;
    For(i,1,n-1){
        vector<int> t1 = pro(i);
        vector<int> t2 = pro(n-i-1);
        //if(i>0){
        int k1 = t1.size();
        int k2 = t2.size();
        int temp = a[0];
        int cnt1 = 0;
        int cnt2 = 0;
        REP(i,k1){
            
            if(t1[i]>0){
                cnt1 += pow(2,k1-i);
                int index1 = cnt1/(int)pow(2,k1-i);
                temp = gcd(temp,d1[k1-1-i][index1-1]);
            }
            
        }
        REP(i,k2){
            
            if(t2[i]>0){
                cnt2 += pow(2,k2-i);
                int index2 = cnt2/(int)pow(2,k2-i);
                temp = gcd(temp,d2[k2-1-i][index2-1]);
            }
            
        }
        chmax(res,temp);
        //}else if(){
            
        //}
    }
    vector<int> t2 = pro(n-1);
    int k2 = t2.size();
    int temp = a.back();
    int cnt2 = 0;
    REP(i,k2){
        
        if(t2[i]>0){
            cnt2 += pow(2,k2-i);
            int index2 = cnt2/(int)pow(2,k2-i);
            temp = gcd(temp,d2[k2-1-i][index2-1]);
        }
        
    }
    chmax(res,temp);
    vector<int> t1 = pro(n-1);
    //if(i>0){
    int k1 = t1.size();
    temp = a[0];
    int cnt1 = 0;
    REP(i,k1){
        
        if(t1[i]>0){
            cnt1 += pow(2,k1-i);
            int index1 = cnt1/(int)pow(2,k1-i);
            temp = gcd(temp,d1[k1-1-i][index1-1]);
        }
        
    }
    
    chmax(res,temp);
    put(res);
    return 0;
}


Measured memory_bytes: 2680