#include <bits/stdc++.h>
using namespace std;
long long P[10000005];
long long is[10000005];
vector<pair<long long, long long> > ss;
long long solve(long long x) {
  long long ch = 1;
  for (long long i = 0; i < ss.size(); i++) {
    long long a = ss[i].first;
    long long b = ss[i].second;
    long long sum = 0;
    for (long long y = a; y <= x; y *= a) {
      sum += x / y;
    }
    if (sum < b) return 0;
  }
  return 1;
}
signed main() {
  long long k;
  cin >> k;
  for (long long i = 0; i < k; i++) {
    long long a;
    cin >> a;
    P[a]++;
  }
  for (long long i = 2; i < 10000005; i++) {
    if (is[i] == 0) {
      for (long long j = i * 2; j < 10000005; j += i) {
        is[j] = 1;
      }
    }
  }
  for (long long i = 10000005 - 1; i >= 2; i--) {
    P[i] = P[i + 1] + P[i];
  }
  for (long long i = 2; i < 10000005; i++) {
    if (is[i] == 1) continue;
    long long val = P[i];
    P[i] = 0;
    for (long long j = i; j < 10000005; j *= i) {
      for (long long l = j; l < 10000005; l += j) {
        P[i] += P[l];
      }
    }
    P[i] += val;
    if (P[i] > 0) ss.push_back(make_pair(i, P[i]));
  }
  long long l = 1, r = 100000000000000;
  long long ans = 0;
  while (r >= l) {
    long long mid = (l + r) / 2LL;
    if (solve(mid) == 1) {
      r = mid - 1;
      ans = mid;
    } else
      l = mid + 1;
  }
  cout << ans << endl;
}
