#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 10;
const long long INF = 1e18;
const int maxk = 1e6 + 5;
const int maxn = 1e7 + 5;
const int mod = 1e9 + 7;
int k;
int a[maxk];
long long cnt[maxn];
bool is_prime[maxn];
int nprimes;
int primes[maxn];
void sieve(int n) {
  fill(is_prime, is_prime + n + 1, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; ++i) {
    if (is_prime[i]) {
      primes[nprimes++] = i;
      for (int j = 2 * i; j <= n; j += i) {
        is_prime[j] = false;
        if (cnt[j]) {
          int tmp = j, f = 0;
          while (tmp % i == 0) {
            tmp /= i;
            ++f;
          }
          cnt[i] += 1LL * f * cnt[j];
          cnt[tmp] += cnt[j];
          cnt[j] = 0;
        }
      }
    }
  }
}
bool check(long long x) {
  for (int i = 0; i < nprimes; ++i) {
    long long tmp = x, f = 0;
    while (tmp) {
      tmp /= primes[i];
      f += tmp;
    }
    if (f < cnt[primes[i]]) return false;
  }
  return true;
}
int MAIN() {
  scanf("%d", &k);
  int mx = -1;
  long long lf = 0, rg = 0;
  for (int i = 0; i < k; ++i) {
    scanf("%d", &a[i]);
    mx = max(mx, a[i]);
    rg += a[i];
    ++cnt[a[i]];
  }
  for (int i = mx - 1; i >= 1; --i) cnt[i] += cnt[i + 1];
  sieve(mx);
  while (lf + 1 < rg) {
    long long mid = (lf + rg) >> 1;
    if (check(mid))
      rg = mid;
    else
      lf = mid;
  }
  printf("%I64d\n", rg);
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  cout << fixed << setprecision(16);
  int ret = MAIN();
  return ret;
}
