#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const int ten[] = {1,      10,      100,      1000,      10000,
                   100000, 1000000, 10000000, 100000000, 1000000000};
const int fact[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
const int N = 1000000;
const int M = 10000000;
bool mark[M + 1];
long long cnt[N], d[M + 1], n, pn, a[N], p[N], factor[M + 1];
bool check(long long x) {
  for (int i = 0; i < pn; i++) {
    long long count = 0;
    for (long long k = p[i]; k <= x && k > 0; k *= p[i]) {
      count += x / k;
      if (count >= cnt[i]) break;
    }
    if (count < cnt[i]) return false;
  }
  return true;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  pn = 0;
  memset(mark, 0, sizeof(mark));
  for (int i = 2; i <= M; i++) {
    if (!mark[i]) {
      factor[i] = pn;
      p[pn++] = i;
    }
    for (int j = 0; j < pn && i * p[j] <= M; j++) {
      mark[i * p[j]] = true;
      factor[i * p[j]] = j;
      if (i % p[j] == 0) break;
    }
  }
  for (int j = n - 1, i = M; i >= 2; i--) {
    while (j >= 0 && a[j] >= i) j--;
    d[i] = n - j - 1;
  }
  memset(cnt, 0, sizeof(cnt));
  for (int i = M; i >= 2; i--) {
    cnt[factor[i]] += d[i];
    d[i / p[factor[i]]] += d[i];
  }
  long long l = a[n - 1], r = a[n - 1] * 1ll * n, mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << endl;
  return 0;
}
