#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int MAX = 202020;
const int INF = 1000000000;
const int ALP = 26;
ll gcd(ll a, ll b) {
  while (b != 0) {
    ll r = a % b;
    a = b;
    b = r;
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll n, a[101010], pl[101010], pr[101010], pf[101010], plcm[101010], gl[101010],
    gr[101010], gf[101010], ggcd[101010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[1] << '\n';
    return 0;
  }
  gl[1] = pl[1] = a[1];
  gr[n] = pr[n] = a[n];
  for (int i = 2; i <= n; i++) pl[i] = lcm(pl[i - 1], a[i]);
  for (int i = n - 1; i >= 1; i--) pr[i] = lcm(pr[i + 1], a[i]);
  for (int i = 2; i <= n; i++) gl[i] = gcd(gl[i - 1], a[i]);
  for (int i = n - 1; i >= 1; i--) gr[i] = gcd(gr[i + 1], a[i]);
  pf[1] = pr[2];
  pf[n] = pl[n - 1];
  gf[1] = gr[2];
  gf[n] = gl[n - 1];
  for (int i = 2; i <= n - 1; i++) {
    gf[i] = gcd(gl[i - 1], gr[i + 1]);
  }
  for (int i = 2; i <= n - 1; i++) {
    pf[i] = lcm(pl[i - 1], pr[i + 1]);
  }
  for (int i = 1; i <= n; i++) {
    plcm[i] = gcd(pf[i], a[i]);
  }
  for (int i = 1; i <= n; i++) {
    ggcd[i] = lcm(gf[i], a[i]);
  }
  ll ans = ggcd[1];
  for (int i = 2; i <= n; i++) {
    ans = gcd(ggcd[i], ans);
  }
  cout << ans << "\n";
  return 0;
}
