#include <bits/stdc++.h>
using namespace std;
const long long const1 = 1e9 + 7;
long long power(long long a, long long b) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    long long t = power(a, b / 2);
    return t * t % const1;
  } else {
    long long t = power(a, b / 2);
    t = t * t % const1;
    return t * a % const1;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> erat(2e6 + 1, -1);
  for (long long i = 2; i <= 2e6; i++) {
    if (erat[i] == -1) {
      long long j = i;
      while (j <= 2e6) {
        erat[j] = i;
        j += i;
      }
    }
  }
  vector<long long> p(n);
  for (long long i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  bool flag = true;
  set<pair<long long, pair<long long, long long> > > st;
  long long c = 1, pp = 0;
  vector<long long> type(n);
  for (long long i = 0; i < n; i++) {
    set<pair<long long, pair<long long, long long> > >::iterator it;
    it = st.lower_bound({p[i], {0, 0}});
    if (it != st.end() && it->first == p[i]) {
      type[i] = 2;
      long long a = p[i] - 1;
      while (a > 1) {
        long long cnt1 = 0;
        long long q = erat[a];
        while (a % q == 0) {
          cnt1++;
          a = a / q;
        }
        it = st.lower_bound({q, {0, 0}});
        if (it == st.end() || it->first != q) {
          st.insert({q, {cnt1, 1}});
        } else if (it->second.first < cnt1) {
          st.erase(*it);
          st.insert({q, {cnt1, 1}});
        } else if (it->second.first == cnt1) {
          long long cnt2 = 1 + it->second.second;
          st.erase(*it);
          st.insert({q, {cnt1, cnt2}});
        }
      }
    } else {
      type[i] = 1;
      st.insert({p[i], {1, 1}});
    }
  }
  set<pair<long long, pair<long long, long long> > >::iterator it;
  for (long long i = 0; i < n; i++) {
    if (type[i] == 1) {
      it = st.lower_bound({p[i], {0, 0}});
      if (it->second.first > 1 || it->second.second > 1) {
        pp = 1;
      }
    } else {
      long long a = p[i] - 1;
      if (p[i] - 1 == 1) {
        pp = 1;
      }
      bool flag = true;
      while (a > 1) {
        long long q = erat[a];
        long long cnt1 = 0;
        while (a % q == 0) {
          cnt1++;
          a = a / q;
        }
        it = st.lower_bound({q, {0, 0}});
        if (it->second.first == cnt1 && it->second.second == 1) {
          flag = false;
        }
      }
      if (flag) {
        pp = 1;
      }
    }
  }
  for (it = st.begin(); it != st.end(); it++) {
    c = c * power(it->first, it->second.first) % const1;
  }
  cout << (c + pp) % const1;
  return 0;
}
