#include <bits/stdc++.h>
using namespace std;
int dv[10000001];
long long cnt[10000001];
long long need[10000001];
void run(int casenr) {
  memset(dv, -1, sizeof(dv));
  for (int i = (2); i <= (10000000); ++i)
    if (dv[i] == -1)
      for (int j = i; j <= 10000000; j += i)
        if (dv[j] == -1) dv[j] = i;
  int k;
  scanf("%d", &k);
  for (int i = (0); i < (k); ++i) {
    int a;
    scanf("%d", &a);
    ++cnt[a];
  }
  long long ret = 1;
  long long sum = 0;
  for (int i = 10000000; i >= 2; --i) {
    sum += cnt[i];
    long long cur = sum + need[i];
    if (cur == 0) continue;
    if (dv[i] != i) {
      need[dv[i]] += cur;
      need[i / dv[i]] += cur;
    } else {
      long long now = 0, left = cur, have = 1, val = i;
      int exp = 1;
      while (have < left) {
        have = have * i + 1;
        val *= i;
        ++exp;
      }
      while (left > 0) {
        if (have - exp >= left) {
          have = (have - 1) / i;
          val /= i;
          --exp;
          continue;
        }
        long long times = (left + exp - have + have - 1) / have;
        left -= times * have;
        now += times * val;
      }
      if (now > ret) ret = now;
    }
  }
  cout << ret << endl;
}
int main() {
  run(1);
  return 0;
}
