#include <bits/stdc++.h>
using namespace std;
const long long M = 10000000;
int k, a[1 << 20], b[M + 10];
bool p[M + 10];
long long solve() {
  for (int i = (int)(0); i < (int)(k); i++) b[a[i]]++;
  for (int i = M; i > 1; i--) b[i] += b[i + 1];
  long long ans = 0;
  p[0] = p[1] = 1;
  for (int i = (int)(0); i < (int)(M + 1); i++)
    if (!p[i]) {
      long long cnt = 0;
      for (int j = i + i; j <= M; j += i) p[j] = 1;
      for (long long j = i; j <= M; j *= i)
        for (long long k = j; k <= M; k += j) cnt += b[k];
      long long lb = 0, ub = M * M, mid, sum;
      while (ub - lb > 1) {
        sum = 0;
        mid = (lb + ub) / 2;
        for (long long j = i; j <= mid; j *= i) sum += mid / j;
        if (sum >= cnt)
          ub = mid;
        else
          lb = mid;
      }
      ans = max(ans, ub);
    }
  return ans;
}
void input() {
  cin >> k;
  for (int i = (int)(0); i < (int)(k); i++) cin >> a[i];
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  input();
  cout << solve() << endl;
  return 0;
}
