#include <bits/stdc++.h>
using namespace std;
long long dp[10000001], expo[700000], expo_ans[700000];
vector<int> primes;
bitset<10000001> bs;
void generar() {
  bs.set();
  for (long long i = 2; i < 10000001; i++)
    if (bs[i]) {
      for (long long j = i * i; j < 10000001; j += i) bs[j] = 0;
      primes.push_back(i);
    }
}
long long maxi;
int main() {
  generar();
  maxi = 0;
  long long n, x, L = 0, R = 0;
  cin >> n;
  for (int i = (0); i < (n); i++) {
    cin >> x;
    maxi = max(maxi, x);
    R += x;
    dp[1]++;
    dp[x + 1]--;
  }
  for (int i = (2); i < (maxi + 1); i++) dp[i] += dp[i - 1];
  int tam = primes.size();
  for (int i = 0; i < tam && primes[i] <= maxi; i++) {
    x = primes[i];
    long long aux = 0;
    while (x <= maxi) {
      for (int j = x; j <= maxi; j += x) aux += dp[j];
      x = x * primes[i];
    }
    expo[i] = aux;
  }
  while (L + 1 < R) {
    long long ans = (L + R) / 2;
    bool ok = true;
    for (int i = 0; i < tam && primes[i] <= maxi; i++) {
      expo_ans[i] = 0;
      x = primes[i];
      while (x <= ans) {
        expo_ans[i] += ans / x;
        x = x * primes[i];
      }
      if (expo_ans[i] < expo[i]) {
        ok = false;
        break;
      }
    }
    if (ok)
      R = ans;
    else
      L = ans;
  }
  cout << R << endl;
  return 0;
}
