#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

template<typename T>
struct segment_tree {
    ll n; std::vector<T> data;
    using F = std::function<T(T, T)>;
    F f; T id;

    segment_tree(std::vector<T> v, F f_, T id_) : f(f_), id(id_) {
        ll size = v.size();
        for (n = 1; n < size; n *= 2);
        data.resize(2 * n - 1, id);

        for (ll i = 0; i < size; i++)
            data[n - 1 + i] = v[i];
        for (ll i = n - 2; i >= 0; i--)
            data[i] = f(data[2 * i + 1], data[2 * i + 2]);
    }

    T query(ll a, ll b, ll x = 0, ll l = 0, ll r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return id;
        if (a <= l && r <= b) return data[x];

        T val_l = query(a, b, 2 * x + 1, l, (l + r) / 2);
        T val_r = query(a, b, 2 * x + 2, (l + r) / 2, r);

        return f(val_l, val_r);
    }
};

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    ll n;
    std::cin >> n;

    vll a(n);
    for (ll i = 0; i < n; i++)
        std::cin >> a[i];

    a.insert(a.begin(), 0), a.insert(a.end(), 0);

    segment_tree<ll> segt(a, gcd, 0);

    ll ans = -1;
    for (ll i = 1; i <= n; i++)
        chmax(gcd(segt.query(0, i), segt.query(i + 1, n + 1)), ans);

    std::cout << ans << '\n';
}


Measured memory_bytes: 6804