// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define all(x) (x).begin(),(x).end()

#define SZ(x) ((int)(x).size())

#define REP(i,n) for(int _n=n, i=0;i<_n;++i)

#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)

#define trav(a, x) for (auto& a : x)

using ull = uint64_t;

using ll = int64_t;

using PII = pair<int, int>;

using VI = vector<int>;

#define INF (1ll<<60)



string to_string(string s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string) s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(pair<A, B> p) {

  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }

template <typename A> string to_string(A v) {

bool first = true; string res = "{";

for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }

res += "}"; return res; }

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {

  cerr << " " << to_string(H); debug_out(T...); }

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)



vector<ll> factors;

vector<ll> factors1;





int main() {

    ios::sync_with_stdio(false), cin.tie(0);

    int n;

    cin >> n;

    vector<ll> A(n);

    // n = 100000;

    // REP(i, n) {

    //     A.pb(1000000000);

    // }

    REP(i, n) cin >> A[i];

    sort(all(A));

    factors.pb(1);

    factors.pb(A[0]);

    factors1.pb(1);

    factors1.pb(A[1]);

    for (int i = 2; i < sqrt(A[0]) + 2; i++) {

        if (A[0] % i == 0) {

            factors.pb(i);

            factors.pb(A[0] / i);

        }

    }

    for (int i = 2; i < sqrt(A[1]) + 2; i++) {

        if (A[1] % i == 0) {

            factors1.pb(i);

            factors1.pb(A[1] / i);

        }

    }

    int ans = 1;

    REP(i, SZ(factors)) {

        int ccc = 0;

        FOR(j, 1, n-1) {

            if (A[j] % factors[i]) {

                ccc++;

                if (ccc > 1) {

                    break;

                }

            }

        }

        if (ccc < 2 && factors[i] > ans) ans = factors[i];

    }

    REP(i, SZ(factors1)) {

        int ccc = 0;

        FOR(j, 0, n-1) {

            if (j == 1) continue;

            if (A[j] % factors1[i]) {

                ccc++;

                if (ccc > 1) {

                    break;

                }

            }

        }

        if (ccc < 2 && factors1[i] > ans) ans = factors1[i];

    }

    cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define all(x) (x).begin(),(x).end()

#define SZ(x) ((int)(x).size())

#define REP(i,n) for(int _n=n, i=0;i<_n;++i)

#define FOR(i,a,b) for(int64_t i=(a),_b=(b);i<=_b;++i)

#define FORD(i,a,b) for(int64_t i=(a),_b=(b);i>=_b;--i)

using ull = uint64_t;

using ll = int64_t;

using PII = pair<int, int>;

using VI = vector<int>;



string to_string(string s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string) s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(pair<A, B> p) {

  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }

template <typename A> string to_string(A v) {

bool first = true; string res = "{";

for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }

res += "}"; return res; }

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {

  cerr << " " << to_string(H); debug_out(T...); }

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)



const ll md = 1000000007;





ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }



int main() {

    ios::sync_with_stdio(false), cin.tie(0);

    int N;

    cin >> N;

    vector<ll> V(N);

    REP(i, N) cin >> V[i];

    vector<ll> pref(N + 3), suff(N + 2);

    pref[0] = V[0];

    FOR(i, 1, N - 1) {

    	pref[i] = gcd(pref[i - 1], V[i]);

    }

    suff[N - 1] = V[N - 1];

    FORD(i, N - 2, 0) {

    	suff[i] = gcd(suff[i + 1], V[i]);

    }

    ll ans = max(suff[1], pref[N - 2]);

    FOR(i, 1, N - 2) {

    	ans = max(ans, gcd(suff[i + 1], pref[i - 1]));

    }

    cout << ans << "\n";





}

// Fastest known solution for this problem: