#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  vector<int> fact(1e7 + 1);
  for (int i = 2; i <= 3162; ++i)
    if (!fact[i])
      for (int j = i * i; j <= 1e7; j += i) fact[j] = i;
  int n, a;
  cin >> n;
  vector<long long> exp(1e7 + 2);
  while (n--) {
    cin >> a;
    ++exp[a];
  }
  for (int i = 1e7; i >= 2; --i) exp[i] += exp[i + 1];
  for (int i = 1e7; i >= 2; --i) {
    if (fact[i]) {
      exp[fact[i]] += exp[i];
      exp[i / fact[i]] += exp[i];
      exp[i] = 0;
    }
  }
  long long ans = 1;
  for (int i = 2; i <= 1e7; ++i) {
    if (ans >= exp[i] * i) continue;
    long long a = max(ans, exp[i] * (i - 1)) / i * i;
    long long b = 0;
    for (long long tmp = a / i; tmp > 0; tmp /= i) b += tmp;
    while (b < exp[i]) {
      a += i;
      ++b;
      for (long long tmp = a / i; tmp % i == 0; tmp /= i) ++b;
    }
    ans = max(ans, a);
  }
  cout << ans;
  return 0;
}
