#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110000;
int N;
int A[Max];

// 素因数分解
void factorization(int n, vector<int>& result)
{
    int a = 2;
    while (n >= a * a) {
        if (n % a == 0) {
            result.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    result.push_back(n);
}

// 最大公約数、最小公倍数
ll gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main(int argc, const char * argv[]) {
    cin >> N;
    inputArray(A, N);

    vector<int> primes;
    map<int, int> countMap;
    map<int, vector<int>> primesMap;
    primes.reserve(Max);
    rep(i, N) {
        factorization(A[i], primes);
        for (auto prime: primes) {
            auto& vec = primesMap[prime];
            vec.resize(N);
            vec[i]++;
        }
        sort(primes.begin(), primes.end());
        primes.erase(unique(primes.begin(), primes.end()), primes.end());
        for (auto prime: primes) {
            countMap[prime]++;
        }
        primes.clear();
    }

    vector<int> targetPrimes;
    for (const auto& countP: countMap) {
        // printf("%d, %d\n",countP.first, countP.second);
        if (countP.second == N-1) {
            targetPrimes.push_back(countP.first);
        }
        // rep(i, N) {
        //     printf("%d ", primesMap[countP.first][i]);
        // }
        // printf("\n");
    }

    map<int, ll> lossMap;
    for (auto prime: targetPrimes) {
        int zeroIdx = 0;
        int commonCount = N;
        rep(i, N) {
            if (primesMap[prime][i] == 0) {
                zeroIdx = i;
                continue;
            }
            if (primesMap[prime][i] < commonCount) {
                commonCount = primesMap[prime][i];
            }
        }
        // printf("lossmap %d,%d,%d\n", prime, zeroIdx, commonCount);
        if (lossMap[zeroIdx] == 0) lossMap[zeroIdx] = 1;
        lossMap[zeroIdx] *= (ll)(pow(prime, commonCount));
    }

    ll maxloss = 0;
    int removeIdx = 0;
    for (const auto& loss: lossMap) {
        if (chmax(maxloss, loss.second)) {
            removeIdx = loss.first;
        }
    }

    ll ans = 0;
    rep(i, N) {
        if (i == removeIdx) continue;
        if (ans == 0) ans = A[i];
        ans = gcd(ans, A[i]);
    }
    // output(removeIdx);
    output(ans);

    return 0;
}

Measured memory_bytes: 4224