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

#define int long long
#define unsigned unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename T>
struct SegmentTree {
    int n;
    T ZERO;
    std::vector<T> data;
    int getSize(int n_) const {
        int ret = 1;
        while (ret < n_) { ret <<= 1; }
        return ret;
    }
    SegmentTree(int n_, T ZERO = T()) : n(getSize(n_)), ZERO(ZERO), data(n << 1, ZERO) {}
    void update(int i, T x) {
        i += n;
        data[i] = x;
        while (i > 1) {
            i >>= 1;
            data[i] = data[i << 1] + data[(i << 1) + 1];
        }
    }
    T operator[](int i) const { return data[i + n]; }
    T getSum(int l, int r) const {
        T ret = ZERO;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) { ret += data[l], l++; }
            if (r & 1) { ret += data[r - 1]; }
        }
        return ret;
    }
};

struct GcdMonoid {
    long long val;
    GcdMonoid() : val(0) {}
    GcdMonoid(long long val) : val(val) {}
    bool operator==(const GcdMonoid &rhs) const { return val == rhs.val; }
    bool operator!=(const GcdMonoid &rhs) const { return val != rhs.val; }
    GcdMonoid &operator+=(const GcdMonoid &rhs) {
        val = gcd(val, rhs.val);
        return *this;
    }
    GcdMonoid operator+(const GcdMonoid rhs) const { return GcdMonoid(*this) += rhs; }
    friend std::istream &operator>>(std::istream &is, GcdMonoid &rhs) {
        long long v;
        is >> v;
        rhs = GcdMonoid(v);
        return is;
    }
    friend std::ostream &operator<<(std::ostream &os, const GcdMonoid &rhs) { return os << rhs.val; }
};

int N;
int A[110000];
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    SegmentTree<GcdMonoid> st(N);
    rep(i, N) { st.update(i, A[i]); }
    int ans = 0;
    rep(i, N) { chmax(ans, (st.getSum(0, i) + st.getSum(i + 1, N)).val); }
    cout << ans << endl;
}

Measured memory_bytes: 3072