#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  vector<int> Fact(1e7 + 1);
  for (int n = 2; n <= 3162; ++n) {
    if (!Fact[n]) {
      for (int m = n * n; m <= 1e7; m += n) {
        Fact[m] = n;
      }
    }
  }
  int N, t;
  cin >> N;
  vector<long long> Count(1e7 + 2);
  while (N--) {
    cin >> t;
    ++Count[t];
  }
  for (int n = 1e7; n >= 2; --n) {
    Count[n] += Count[n + 1];
  }
  for (int n = 1e7; n >= 2; --n) {
    if (Fact[n]) {
      Count[Fact[n]] += Count[n];
      Count[n / Fact[n]] += Count[n];
      Count[n] = 0;
    }
  }
  long long Ans = 1;
  long long x, y, temp;
  for (int n = 2; n <= 1e7; ++n) {
    if (Ans >= Count[n] * n) {
      continue;
    }
    x = max(Ans, Count[n] * (n - 1)) / n * n;
    y = 0;
    for (temp = x / n; temp > 0; temp /= n) {
      y += temp;
    }
    while (y < Count[n]) {
      x += n;
      ++y;
      for (temp = x / n; temp % n == 0; temp /= n) {
        ++y;
      }
    }
    Ans = max(Ans, x);
  }
  cout << Ans << endl;
  return 0;
}
