#include <bits/stdc++.h>   using namespace std;   const int N = 2e6 + 7, M = 1e9 + 7;   vector<int> primes;   bool isp[N];   void sieve() {     fill(isp, isp + N, 1);     isp[0] = isp[1] = 0;     for (int i = 2; i * i < N; i++)       if (isp[i])         for (int j = i * i; j < N; j += i) isp[j] = 0;     for (int i = 2; i < N; i++)       if (isp[i]) primes.push_back(i);   }   vector<pair<int, int> > factorize(int x) {     vector<pair<int, int> > ans;     for (int i = 2; i * i <= x; i++) {       int cnt = 0;       while (x % i == 0) cnt++, x /= i;       if (cnt) ans.push_back(make_pair(i, cnt));     }     if (x > 1) ans.push_back(make_pair(x, 1));     return ans;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     long long ans = 1;     map<int, int> fac;     map<int, int> cnt;     vector<vector<pair<int, int> > > factors;     int pp[n];     for (int i = 0; i < n; i++) cin >> pp[i];     sort(pp, pp + n);     reverse(pp, pp + n);     for (int i = 1; i <= n; i++) {       int p = pp[i - 1];       if (fac.count(p) == 0) {         ans = (ans * p) % M;         fac[p] = 1;         cnt[p] = 1;         vector<pair<int, int> > v;         v.push_back(make_pair(p, 1));         factors.push_back(v);       } else {         vector<pair<int, int> > pf = factorize(p - 1);         factors.push_back(pf);         for (auto pr : pf) {           int p = pr.first;           int e = pr.second;           int dif = e - fac[p];           if (dif < 0) continue;           if (dif == 0) {             cnt[p]++;             continue;           }           fac[p] += dif;           cnt[p] = 1;           for (int i = 0; i < dif; i++) ans = (ans * p) % M;         }       }     }     for (auto pf : factors) {       bool found = true;       for (auto pr : pf) {         int p = pr.first;         int e = pr.second;         int mx = fac[p];         assert(e <= mx);         if (e == mx && cnt[p] == 1) {           found = false;           break;         }       }       if (found) {         ans++;         break;       }     }     cout << ans << endl;   }   