#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long a[maxn], suf[maxn];
int main() {
  long long n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = n; i >= 1; i--) suf[i] = gcd(suf[i + 1], a[i]);
  for (int i = 1; i <= n; i++) ans = gcd(ans, lcm(a[i], suf[i + 1]));
  cout << ans << endl;
  return 0;
}
