#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int ll_max = 1e6;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int findlcm(vector<long long int> arr, long long int n) {
  long long int ans = arr[0];
  for (long long int i = 1; i < n; i++)
    ans = (((arr[i] * ans)) / (gcd(arr[i], ans)));
  return ans;
}
long long int findGCD(vector<long long int> arr, long long int n) {
  long long int result = arr[0];
  for (long long int 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 int n, m;
  long long int j, y, z, x, T, i;
  long long int k, t;
  long long int b, c;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  vector<long long int> suff(n);
  for (long long int i = n - 1; i >= 0; i--) {
    if (i == n - 1)
      suff[i] = a[i];
    else
      suff[i] = gcd(suff[i + 1], a[i]);
  }
  vector<long long int> dum;
  for (long long int i = 0; i < n - 1; i++) {
    dum.push_back(lcm(a[i], suff[i + 1]));
  }
  cout << findGCD(dum, dum.size());
  return 0;
}
