#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10001001;
int min_div[MAXN];
vector<long long> primes;
void criba() {
  for (int i = (int)0; i < (int)MAXN; i++) min_div[i] = i;
  for (int i = (int)2; i < (int)MAXN; i++) {
    if (min_div[i] != i) continue;
    primes.push_back(i);
    for (int j = i + i; j < MAXN; j += i) {
      min_div[j] = i;
    }
  }
}
void solve(long long* acum) {
  long long now = acum[MAXN - 1];
  for (int i = MAXN - 2; i > 1; i--) {
    now += acum[i];
    acum[i] = now;
  }
  for (int i = MAXN - 1; i > 1; i--)
    if (acum[i]) {
      if (min_div[i] == i) continue;
      int a = min_div[i];
      int b = i / min_div[i];
      acum[a] += acum[i];
      acum[b] += acum[i];
      acum[i] = 0;
    }
}
long long acum_a[MAXN];
bool test(long long n) {
  for (int i = (int)0; i < (int)primes.size(); i++) {
    long long e = 0;
    long long n_t = n;
    while (n_t) {
      e += (n_t /= (long long)primes[i]);
    }
    if (e < acum_a[primes[i]]) return false;
  }
  return true;
}
int main() {
  criba();
  int k;
  scanf("%d", &k);
  long long lo = 1, hi = 0;
  for (int i = (int)0; i < (int)k; i++) {
    int n = 1000101;
    scanf("%d", &n);
    acum_a[n]++;
    hi += n;
  }
  solve(acum_a);
  while (lo < hi) {
    long long mid = (lo + hi) / 2LL;
    if (test(mid)) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }
  cout << lo << endl;
  return 0;
}
