#include <bits/stdc++.h>
const long long M = 1e9 + 7;
using namespace std;
long long ans = 1;
long pr[2000005], primeid[2000005], cnt[2000005], nump = 0, n, x, i, j, k, tmp,
                                                  listp[2000005], id[2000005];
vector<long> maxid[2000005], num[2000005];
bool f[2000005] = {1, 1}, fl[2000005], vis[2000005], isp[2000005], plus1s;
bool cmp(vector<long> a, vector<long> b) { return a.size() > b.size(); }
int main() {
  for (i = 2; i <= 2000005 - 5; i++) {
    if (!f[i]) pr[++nump] = i, primeid[i] = nump;
    for (j = 1; j <= nump && i * pr[j] <= 2000005 - 5; j++) {
      f[i * pr[j]] = 1;
      if (i % pr[j] == 0) break;
    }
  }
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x;
    if (cnt[x] == 0)
      cnt[x] = 1, fl[x] = 1, id[x] = i, maxid[x].push_back(i);
    else {
      long p = 0, q = 1;
      listp[1] = x - 1;
      while (p < q) {
        p++;
        tmp = listp[p];
        for (j = 1; j <= nump && tmp >= pr[j]; j++) {
          long s = 0;
          while (tmp % pr[j] == 0) s++, tmp /= pr[j];
          if (s > 0 && fl[pr[j]])
            q++, listp[q] = pr[j] - 1, fl[pr[j]] = 0, maxid[pr[j]].clear();
          if (s > cnt[pr[j]]) {
            cnt[pr[j]] = s, maxid[pr[j]].clear();
            maxid[pr[j]].push_back(p == 1 ? i : id[listp[p] + 1]);
          } else if (s == cnt[pr[j]] && s != 0)
            maxid[pr[j]].push_back(p == 1 ? i : id[listp[p] + 1]);
          if (!f[tmp]) j = primeid[tmp] - 1;
        }
      }
    }
  }
  for (i = 1; i <= nump; i++)
    for (j = 0; j < maxid[pr[i]].size(); j++)
      num[maxid[pr[i]][j]].push_back(pr[i]);
  sort(num + 1, num + n + 1, cmp);
  for (i = 1; i <= n; i++) {
    bool pp = 0;
    for (j = 0; j < num[i].size(); j++)
      if (!vis[num[i][j]]) vis[num[i][j]] = 1, pp = 1;
    if (!pp) {
      plus1s = 1;
      break;
    }
  }
  for (i = 2; i < 2000005; i++)
    for (j = 1; j <= cnt[i]; j++) ans = ans * i % M;
  if (plus1s) ans = (ans + 1) % M;
  cout << ans;
}
