#include <bits/stdc++.h>
using namespace std;
namespace mine {
void chmax(int &x, const long long y) { x = (x > y ? x : y); }
void chmin(int &x, const long long y) { x = (x < y ? x : y); }
long long qread() {
  long long ans = 0, f = 1;
  char c = getchar();
  while (c < '0' or c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c and c <= '9') ans = ans * 10 + c - '0', c = getchar();
  return ans * f;
}
void write(long long num) {
  if (num < 0) putchar('-'), num = -num;
  if (num >= 10) write(num / 10);
  putchar('0' + num % 10);
}
void write1(long long num) {
  write(num);
  putchar(' ');
}
void write2(long long num) {
  write(num);
  putchar('\n');
}
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
  if (a <= -MOD) a += MOD;
}
long long qpower(long long x, int e) {
  long long ans = 1;
  while (e) {
    if (e & 1) ans = ans * x % MOD;
    x = x * x % MOD;
    e >>= 1;
  }
  return ans;
}
long long invm(long long x) { return qpower(x, MOD - 2); }
const int MAX_N = 2e6 + 10;
bool gg[MAX_N];
int pp = 0, prm[MAX_N], mip[MAX_N];
void pre() {
  for (int i = 2; i < MAX_N; i++) {
    if (!gg[i]) prm[++pp] = i, mip[i] = pp;
    for (int j = 1; j <= pp and (long long) prm[j] * i < MAX_N; j++) {
      int to = prm[j] * i;
      gg[to] = 1;
      mip[to] = j;
      if (i % prm[j] == 0) break;
    }
  }
}
int p[MAX_N];
pair<int, int> cnt[MAX_N];
void insert(int id, int num) {
  if (num >= cnt[id].first)
    cnt[id].second = cnt[id].first, cnt[id].first = num;
  else if (num > cnt[id].second)
    cnt[id].second = num;
}
bool fine(int now) {
  if (now <= 0) return 0;
  while (now > 1) {
    int t = 0, id = mip[now];
    while (now % prm[id] == 0) now /= prm[id], t++;
    if (cnt[id].first != cnt[id].second and cnt[id].first == t) return 0;
  }
  return 1;
}
void main() {
  pre();
  int n = qread();
  for (int i = 1; i <= n; i++) p[i] = qread();
  sort(p + 1, p + n + 1);
  for (int i = n; i >= 1; i--) {
    if (!cnt[mip[p[i]]].first) {
      cnt[mip[p[i]]].first = 1;
      p[i] = 0;
      continue;
    }
    int now = p[i] - 1;
    while (now > 1) {
      int t = 0, id = mip[now];
      while (now % prm[id] == 0) now /= prm[id], t++;
      insert(id, t);
    }
  }
  bool bk = 0;
  for (int i = 1; i <= n; i++)
    if (fine(p[i] - 1)) {
      bk = 1;
      break;
    }
  long long ans = 1;
  for (int i = 1; i <= pp; i++) {
    while (cnt[i].first--) ans = ans * prm[i] % MOD;
  }
  write((ans + bk) % MOD);
}
};  // namespace mine
int main() {
  srand(time(0));
  mine::main();
}
