#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long findGCD(vector<long long> arr) {
  long long n = arr.size();
  long long result = arr[0];
  for (long long i = 1; i < n; i++) {
    result = gcd(arr[i], result);
    if (result == 1) {
      return 1;
    }
  }
  return result;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n, 0);
  vector<long long> lst;
  vector<long long> gcds(n, 0);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  gcds[n - 1] = a[n - 1];
  for (long long i = n - 2; i >= 0; i--) {
    gcds[i] = gcd(gcds[i + 1], a[i]);
  }
  for (long long i = 0; i < n - 1; i++) {
    lst.push_back(lcm(a[i], gcds[i + 1]));
  }
  cout << findGCD(lst) << endl;
  return 0;
}
