You are given a tuple generator $$$f^{(k)} = (f_1^{(k)}, f_2^{(k)}, \dots, f_n^{(k)})$$$, where $$$f_i^{(k)} = (a_i \cdot f_i^{(k - 1)} + b_i) \bmod p_i$$$ and $$$f^{(0)} = (x_1, x_2, \dots, x_n)$$$. Here $$$x \bmod y$$$ denotes the remainder of $$$x$$$ when divided by $$$y$$$. All $$$p_i$$$ are primes.One can see that with fixed sequences $$$x_i$$$, $$$y_i$$$, $$$a_i$$$ the tuples $$$f^{(k)}$$$ starting from some index will repeat tuples with smaller indices. Calculate the maximum number of different tuples (from all $$$f^{(k)}$$$ for $$$k \ge 0$$$) that can be produced by this generator, if $$$x_i$$$, $$$a_i$$$, $$$b_i$$$ are integers in the range $$$[0, p_i - 1]$$$ and can be chosen arbitrary. The answer can be large, so print the remainder it gives when divided by $$$10^9 + 7$$$

The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in the tuple. The second line contains $$$n$$$ space separated prime numbers — the modules $$$p_1, p_2, \ldots, p_n$$$ ($$$2 \le p_i \le 2 \cdot 10^6$$$).

Print one integer — the maximum number of different tuples modulo $$$10^9 + 7$$$.

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int mx[2020202],cnt[2020202];
bool mk[202020];
int p[202020];
bool cmp(const int &x,const int &y)
{
	return x>y;
}
int main()
{
	int n,pp,now,ans=1;
	bool ok;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);
	sort(p+1,p+1+n,cmp);
	for(int i=1;i<=2000000;i++)
	{
		mx[i]=1;
		cnt[i]=0;
	}
	memset(mk,0,sizeof(mk));
	for(int i=1;i<=n;i++)
	{
		if(mx[p[i]]==1)
		{
			mx[p[i]]=p[i];
			cnt[p[i]]=1;
			mk[i]=true;
			continue;
		}
		pp=p[i]-1;
		for(int j=2;j*j<=pp;j++)
			if(pp%j==0)
			{
				now=1;
				while(pp%j==0)
				{
					now*=j;
					pp/=j;
				}
				if(now>mx[j])
				{
					mx[j]=now;
					cnt[j]=1;
				}
				else if(now==mx[j])
					cnt[j]++;
			}
		if(pp!=1)
		{
			if(pp>mx[pp])
			{
				mx[pp]=pp;
				cnt[pp]=1;
			}
			else if(pp==mx[pp])
				cnt[pp]++;
		}
	}
	for(int i=1;i<=2000000;i++)
		ans=(long long)ans*mx[i]%mod;
	for(int i=1;i<=n;i++)
		if(!mk[i])
		{
			pp=p[i]-1;
			ok=true;
			for(int j=2;j*j<=pp;j++)
				if(pp%j==0)
				{
					now=1;
					while(pp%j==0)
					{
						now*=j;
						pp/=j;
					}
					if(now==mx[j]&&cnt[j]==1)
						ok=false;
				}
			if(pp!=1&&mx[pp]==pp&&cnt[pp]==1)
				ok=false;
			if(ok)
			{
				ans=(ans+1)%mod;
				break;
			}
		}
	printf("%d",ans);
	return 0;
}

#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
using namespace std;
typedef pair<int,int> Pii;
const int N = 2000020,mo=1e9+7;
int n,a[N],prime[N],len,mrk[N],c[N];Pii b[N];
void getp(int n){
	rep(i,2,n){
		if(!mrk[i])prime[++len]=i;
		rep(j,1,len){
			if(i*prime[j]>n)break;
			mrk[i*prime[j]]=prime[j];if(i%prime[j]==0)break;
		}
	}
}
vector<Pii>solve(int x){
	vector<Pii>res;
	while(mrk[x]){
		int c=0,v=mrk[x];while(x%v==0)x/=v,c++;res.push_back(Pii(v,c));
	}
	if(x>1)res.push_back(Pii(x,1));
	return res;
}
int main(){
	getp(2000000);scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);bool ok=0;
	per(i,n,1)
	if(!b[a[i]].fi)b[a[i]]=Pii(1,1),c[i]=a[i];
	else{
		vector<Pii>f=solve(a[i]-1);per(i,SZ(f)-1,0){
			int x=f[i].fi,y=f[i].se;
			if(y>b[x].fi)b[x]=Pii(y,1);else if(y==b[x].fi)b[x].se++;
		}
		c[i]=a[i]-1;
	}
	rep(i,1,n){
		vector<Pii>f=solve(c[i]);bool bo=1;
		per(i,SZ(f)-1,0){
			int x=f[i].fi,y=f[i].se;
			bo&=!(y==b[x].fi&&b[x].se==1);
		}
		ok|=bo;
	}
	int res=1;rep(i,1,2000000)per(j,b[i].fi,1)res=1LL*res*i%mo;if(ok)res=(res+1)%mo;
	cout<<res;
	return 0;
}

#include <bits/stdc++.h>
#define finish(x) return cout << x << endl, 0
typedef long long ll;
typedef long double ldb;
const int md = 1e9 + 7;
const ll inf = 4e18;
const int OO = 1;
const int OOO = 1;
using namespace std;

const int M = 2e6 + 10;

int n;
vector<int> a;
vector<int> useful;
map<int, int> have;
ll ans = 1;

int sieve[M], cnt[M];
vector<pair<int, int>> ind[M];

void preprocess() {
	int i = 2;
	for (; i * i <= M; i++) {
		if (!sieve[i]) {
			sieve[i] = i;
			for (int j = i * i; j < M; j += i)
				if (!sieve[j])
					sieve[j] = i;
		}
	}
	for (; i < M; i++)
		if (!sieve[i])
			sieve[i] = i;
}

void work(int val, int i) {
	if (val == 1) return;
	int p = sieve[val], c = 0;
	while (val % p == 0) {
		c++;
		val /= p;
	}
	ind[p].emplace_back(c, i);
	while (cnt[p] < c) {
		cnt[p]++;
		ans = (ans * p) % md;
	}
	work(val, i);
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	preprocess();
	cin >> n;
	a.resize(n);
	useful.resize(n, 0);
	for (auto &i : a) cin >> i;
	sort(a.rbegin(), a.rend());

	for (int i = 0; i < n; i++) {
		int x = a[i];
		if (have[x] >= 2) continue;
		ll cur = ans;
		work(x - have[x], i);
		have[x]++;
		if (have[x] == 1 && cur == ans) {
			ind[x].pop_back();
			work(x - 1, i);
			have[x]++;
		}
	}
	for (int i = 2; i < M; i++) {
		if (ind[i].size() == 0) continue;
		auto mx = *max_element(ind[i].begin(), ind[i].end());
		bool found = false;
		for (const auto &j : ind[i])
			if (mx.first == j.first && mx.second != j.second) found = true;
		if (!found)
			useful[mx.second] = 1;
	}
	if (*min_element(useful.begin(), useful.end()) == 0)
		ans = (ans + 1) % md;
	finish(ans);
}

#include <algorithm>
#include <functional>
#include <stdio.h>
#define cmax(x, y) ((y)>x?x=(y),1:0)
int F() {
	register int a;
	register char c;
	while(c=getchar(), c<'0'||c>'9');
	for(a=c-'0'; c=getchar(), c>='0'&&c<='9'; a=a*10+c-'0');
	return a;
}
const int N=2e5, M=2e6+5, P=1e9+7;
int p[N], q[N], mp[M], pr[M], times[M], maxcnt[M];
void clcm(register int x) {
	register int id, cur, cnt;
	while(x!=1) {
		cur=pr[id=mp[x]];
		for(cnt=0; x%cur==0; x/=cur) ++cnt;
		if(times[id]==cnt) ++maxcnt[id];
		if(cmax(times[id], cnt)) maxcnt[id]=1;
	}
}
bool check(register int x) {
	register int id, cur, cnt;
	register bool ans=1;
	while(x!=1) {
		cur=pr[id=mp[x]];
		for(cnt=0; x%cur==0; x/=cur) ++cnt;
		if(times[id]==cnt && maxcnt[id]==1) ans=0;
	}
	return ans;
}
int main() {
	register int n, m, i, j, cnt=0, ans=1;
	register bool inc=0;
	n=F();
	for(i=0; i<n; ++i) p[i]=F();
	std::sort(p, p+n, std::greater<int>());
	m=p[0];
	for(i=2; i<=m; ++i) {
		if(!mp[i]) pr[mp[i]=++cnt]=i;
		for(j=1; j<=cnt && i*pr[j]<=m; ++j) {
			mp[i*pr[j]]=j;
			if(i%pr[j]==0) break;
		}
	}
	for(i=0; i<n; ++i) clcm(q[i] =p[i]-(bool)times[mp[p[i]]]);
	for(i=1; i<=cnt; ++i) {
		for(j=1; j<=times[i]; ++j) {
			ans=(long long)ans*pr[i]%P;
		}
	}
	for(i=0; i<n; ++i) inc|=check(q[i]);
	printf("%d\n", (ans+inc)%P);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 2000010;
int n, cnt[N], mx = 0;
int pri[N], d[N], ds[N];
bool ty[N];

inline int add(const int &x, const int &y) {
	return x + y < mod ? x + y : x + y - mod;
}
inline int sub(const int &x, const int &y) {
	return x - y < 0 ? x - y + mod : x - y;
}
inline int mul(const int &x, const int &y) { return (int)((ll)x * y % mod); }
inline int Max(const int &x, const int &y) { return x > y ? x : y; }
void mdy(int i, int x) {
	x > d[i] ? d[i] = x, ds[i] = 1 : x == d[i] ? ++ds[i] : 0;
}
int main() {
	scanf("%d", &n);
	for(int i = 1, x; i <= n; i++)
		scanf("%d", &x), mx = Max(mx, x), ++cnt[x];
	for(int i = 2; i <= mx; i++) if(!pri[i])
		for(int j = i; j <= mx; j += i) if(!pri[j]) pri[j] = i;
	int Circle = 1, Pre = 0;
	for(int i = mx; i; i--) for(int j = cnt[i]; j--;) {
		if(d[i]) {
			for(int x = i - 1; x > 1;) {
				int p = pri[x], c = 0; for(; x % p == 0; x /= p) ++c;
				for(int e = d[p]; e < c; ++e) Circle = mul(Circle, p);
				mdy(p, c);
			}
			ty[i] = 1;
		}
		else mdy(i, 1), Circle = mul(Circle, i);
	}
	for(int i = mx; i; i--) if(ty[i]) {
		bool flag = 1;
		for(int x = i - 1; x > 1;) {
			int p = pri[x], c = 0; for(; x % p == 0; x /= p) ++c;
			if(c == d[p] && ds[p] == 1) flag=0;
		}
		if(flag) Pre = 1;
	}
	printf("%d\n", add(Circle, Pre));
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> pii;

const int MAXP = 2e6 + 5;
const int MOD = 1e9 + 7;

int N;
int p[MAXP];
int cnt[MAXP];
vector <int> adj[MAXP];
vector < vector <pii> > all;
int mx1[MAXP], mx2[MAXP];

void load() {
	scanf("%d", &N);
	while (N--) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
}

inline int mul(int x, int y) {
	return (long long)x * y % MOD;
}

void add(int x) {
	vector <pii> f;
	while (x > 1) {
		int t = p[x], ex = 0;
		for (; !(x % t); x /= t)
			ex++;
		if (ex >= mx1[t]) {
			mx2[t] = mx1[t];
			mx1[t] = ex;
		}
		else if (ex > mx2[t])
			mx2[t] = ex;
		f.push_back({t, ex});
	}
	all.push_back(f);
}

void dfs(int x) {
	cnt[x] = 0;
	add(x - 1);
	for (auto it : adj[x])
		if (cnt[it])
			dfs(it);
}

int solve() {
	for (int i = 2; i < MAXP; i++)
		if (!p[i])
			for (int j = i; j < MAXP; j += i)
				if (!p[j])
					p[j] = i;

	for (int i = 2; i < MAXP; i++)
	 	if (cnt[i])
			for (int j = i + 1; j < MAXP; j += i)
				if (cnt[j])
					adj[j].push_back(i);

	bool ok = false;
	for (int i = MAXP - 1; i; i--)
		if (cnt[i]) {
			add(i);
			ok |= cnt[i] > 2;
			if (cnt[i] > 1)
				dfs(i);
		}

	for (auto it : all) {
		bool tmp = true;
		for (auto curr : it)
			tmp &= mx2[curr.first] >= curr.second;
		ok |= tmp;
	}

	int sol = 1;
	for (int i = 1; i < MAXP; i++)
		while (mx1[i]--)
			sol = mul(sol, i);

	return (sol + ok) % MOD;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10, A = 2e6 + 10, mod = 1e9 + 7;

int p[N], max_pwr[A], ctr[A], idx[A];
vector<int> primes;
bool not_prime[A];

void sieve();
ll pwr(ll x, ll e);

int main() {
	fast_cin();
	sieve();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> p[i];
	}
	sort(p + 1, p + 1 + n);
	ll ans = 1;
	set<int> check;
	for (int i = n; i >= 1; --i) {
		if (!max_pwr[idx[p[i]]]) {
			max_pwr[idx[p[i]]] = 1;
			ctr[idx[p[i]]] = 1;
			ans = (ans * p[i]) % mod;
		} else {
			check.insert(p[i] - 1);
			int temp = p[i] - 1, sq = sqrt(temp);
			for (int j = 0; primes[j] <= sq; ++j) {
				int c = 0;
				while (temp % primes[j] == 0) {
					temp /= primes[j];
					++c;
				}
				if (c > max_pwr[j]) {
					ans = (ans * pwr(primes[j], c - max_pwr[j])) % mod;
					max_pwr[j] = c;
					ctr[j] = 1;
				} else if (c == max_pwr[j]) {
					++ctr[j];
				}
			}
			if (temp > 1) {
				if (1 > max_pwr[idx[temp]]) {
					ans = (ans * temp) % mod;
					max_pwr[idx[temp]] = 1;
					ctr[idx[temp]] = 1;
				} else if (1 == max_pwr[idx[temp]]) {
					++ctr[idx[temp]];
				}
			}
		}
	}
	for (auto &i : check) {
		int temp = i, sq = sqrt(temp);
		bool need = false;
		for (int j = 0; primes[j] <= sq; ++j) {
			int c = 0;
			while (temp % primes[j] == 0) {
				temp /= primes[j];
				++c;
			}
			if (c == max_pwr[j] and ctr[j] == 1) {
				need = true;
				break;
			}
		}
		if (temp > 1 and ctr[idx[temp]] == 1) {
			need = true;
		}
		if (!need) {
			ans = (ans + 1) % mod;
			break;
		}
	}
	cout << ans << endl;
}

void sieve() {
	for (int i = 2; i < A; ++i) {
		if (!not_prime[i]) {
			primes.pb(i);
			idx[i] = primes.size() - 1;
			for (int j = i; j < A; j += i) {
				not_prime[j] = true;
			}
		}
	}
}

ll pwr(ll x, ll e) {
	ll ans = 1;
	x %= mod;
	while (e) {
		if (e & 1) {
			ans = (ans * x) % mod;
		}
		x = (x * x) % mod;
		e /= 2;
	}
	return ans;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long LL;
const int N = 2e6 + 50;
const LL mod = 1e9 + 7;

inline LL Pow(LL x, LL exp) {
  LL res = 1;
  for (; exp; exp >>= 1, x = x * x % mod)
    if (exp & 1) res = res * x % mod;
  return res;
}

int pri[N / 3], m;
bool notp[N];
vector <int> divi[N];

inline void Init() {
  for (int i = 2; i < N; i ++)
    divi[i].reserve(8);
  for (int i = 2; i < N; i ++)
    if (!notp[i]) {
      pri[++ m] = i;
      divi[i].push_back(i);
      for (int j = i + i; j < N; j += i) {
        notp[j] = 1;
        divi[j].push_back(i);
      }
    }
}

int n, a[N], cnt[N], num[N], state[N];

inline void Insert(int x) {
  int t = x;
  for (auto i : divi[x]) {
    int c = 0;
    while (t % i == 0) {
      t /= i; c ++;
    }
    if (cnt[i] < c) cnt[i] = c, num[i] = 1;
    else if (cnt[i] == c) num[i] ++;
  }
}

inline bool check(int x) {
  int t = x;
  for (auto i : divi[x]) {
    int c = 0;
    while (t % i == 0) {
      t /= i; c ++;
    }
    if (cnt[i] == c && num[i] == 1) return 0;
  }
  return 1;
}

int main() {
  Init();
  scanf("%d", &n);
  for (int i = 1, x; i <= n; i ++) {
    scanf("%d", &x); a[x] ++;
  }
  bool add = 0;
  for (int i = 1; i < N; i ++) {
    if (a[i] > 2) add = 1;
    if (a[i] >= 2) {
      Insert(i); Insert(i - 1);
      state[i] = 3;
    }
  }
  for (int i = N - 1; i; i --)
    if (a[i] == 1) {
      if (cnt[i]) Insert(i - 1), state[i] = 1;
      else Insert(i), state[i] = 2;
    }
  for (int i = 1; i < N && !add; i ++) {
    if (state[i] & 1) add |= check(i - 1);
    if (state[i] & 2) add |= check(i);
  }
  LL ans = 1;
  for (int i = 2; i < N; i ++)
    if (cnt[i]) ans = ans * Pow(i, cnt[i]) % mod;
  printf("%lld\n", (ans + add) % mod);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 2000006;
int freq[N];
int g[N];
map<int, int> ms[N];
int mx[N];
int factor[N];
const int mod = 1e9 + 7;
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}

inline int inv(int a){ return powr(a, mod - 2);}
vector<pii> changes;
int ans = 1;
int getChange(int x){
	int ret = 1;
	changes.clear();
	while(x != 1){
		int p = factor[x];
		int k = 0;
		while(x % p == 0){
			x /= p;
			k++;
		}
		if(mx[p] < k){
			changes.push_back({p, mx[p]});
			ret = mul(ret, powr(p, k - mx[p]));
			mx[p] = k;
		}
	}

	reverse(changes.begin(), changes.end());
	for(auto it : changes) mx[it.F] = it.S;
	return ret;
}

void add(int x){
	// trace(x);
	while(x != 1){
		int p = factor[x];
		int k = 0;
		while(x % p == 0){
			x /= p;
			k++;
		}
		if(mx[p] < k){
			ans = mul(ans, powr(p, k - mx[p]));
			// trace(p, k - mx[p], ans);
			mx[p] = k;
		}
		ms[p][k]++;
	}
}

bool canRemove(int x){
	while(x != 1){
		int p = factor[x];
		int k = 0;
		while(x % p == 0){
			x /= p;
			k++;
		}
		if(mx[p] == k){
			if(ms[p][k] == 1) return 0;
		}
	}
	return 1;
}

bool P[N], Q[N];
bool R[N];

int main(){
	int n; sd(n);
	for(int i = 2; i < N; i++){
		if(!factor[i])
			for(int j = i; j < N; j += i) factor[j] = i;
	}

	for(int i = 1; i <= n; i++){
		int x;
		sd(x);
		freq[x]++;
	}

	for(int i = N - 1; i >= 2; i--){
		if(freq[i] >= 2){
			add(i);
			add(i - 1);
			P[i] =Q[i] = 1;
		} else if(freq[i] == 1){
			int x1 = getChange(i), x2 = getChange(i - 1);
			if(x1 > x2){
				add(i);
				P[i] = 1;
			}
			else{
				add(i - 1);
				Q[i] = 1;
			}
		}
		if(freq[i] > 2) R[i] = 1;
	}

	for(int i = 2; i < N; i++){
		if(R[i]){
			ans = add(ans, 1);
			printf("%d\n", ans);
			return 0;
		}
		if(P[i]){
			if(canRemove(i)){
				ans = add(ans, 1);
				printf("%d\n", ans);
				return 0;
			}
		}
		if(Q[i]){
			if(canRemove(i - 1)){
				ans = add(ans, 1);
				printf("%d\n", ans);
				return 0;
			}
		}
	}
	printf("%d\n", ans);
}

#include <bits/stdc++.h>
#define maxn 200020
#define maxm 2000020
#define mo 1000000007
using namespace std;

inline int read(){
	int x=0,f=1;char cc=getchar();
	while(cc<'0' || cc>'9') {if(cc=='-') f=-1;cc=getchar();}
	while(cc>='0' && cc<='9') {x=x*10+cc-'0';cc=getchar();}
	return x*f;
}

int n,a[maxm],g[maxm],p[maxn],pnum,b[maxm],d[maxm],m=2000000,tmp,ans;

inline int ksm(int a,int b){
	int tmp=1;
	while(b){
		if(b&1) tmp=(1ll*tmp*a)%mo;
		a=(1ll*a*a)%mo;
		b>>=1;
	}
	return tmp;
}

inline int kk(int a,int b,int c){
	int tmp=1;
	while(b){
		if(b&1) tmp=(1ll*tmp*a)%c;
		a=(1ll*a*a)%c;
		b>>=1;
	}
	return tmp;
}

int main(){
	n=read();
	for(int i=1;i<=n;i++) a[read()]++;
	pnum=0;
	for(int i=2;i<=2000;i++){
		int flag=0;
		for(int j=2;j<=i-1;j++) if(i%j==0) flag=1;
		if(!flag){
			pnum++;p[pnum]=i;
		}
	}
	ans=0;
	for(int i=m;i>=3;i--){
		if(a[i]==0) continue;
		if(a[i]>=3) ans=1;
		if(g[i]==0){
			g[i]=1;a[i]--;
		}
		if(a[i]==0) continue;
		int y=i-1;
		b[i]=y;
		for(int j=1;j<=pnum;j++){
			if(p[j]*p[j]>b[i]) break;
			if(y%p[j]>0) continue;
			int c=0;
			while(y%p[j]==0){
				c++;y/=p[j];
			}
			g[p[j]]=max(g[p[j]],c);
		}
		if(y>1) g[y]=max(g[y],1);
	}
	for(int i=m;i>=3;i--){
		if(b[i]==0) continue;
		int y=b[i];
		for(int j=1;j<=pnum;j++){
			if(p[j]*p[j]>b[i]) break;
			if(y%p[j]>0) continue;
			int c=0;
			while(y%p[j]==0){
				c++;y/=p[j];
			}
			if(g[p[j]]==c) d[p[j]]++;
		}
		if(y>1 && g[y]==1) d[y]++;
	}
	for(int i=m;i>=3;i--){
		if(b[i]==0) continue;
		int flag=0;
		int y=b[i];
		for(int j=1;j<=pnum;j++){
			if(p[j]*p[j]>b[i]) break;
			if(y%p[j]>0) continue;
			int c=0;
			while(y%p[j]==0){
				c++;y/=p[j];
			}
			if(d[p[j]]==1 && g[p[j]]==c) flag=1;
		}
		if(y>1 && d[y]==1 && g[y]==1) flag=1;
		if(!flag){
			ans=1;break;
		}
	}
	if(g[2]>0 && a[2]>0) ans=1;
	if(a[2]>=2) ans=1;
	if(g[2]==0 && a[2]>0) g[2]=1;
	tmp=1;
	for(int i=2;i<=m;i++) if(g[i]>0) tmp=(1ll*tmp*ksm(i,g[i]))%mo;
	ans=(ans+tmp)%mo;
	printf("%d",ans);
}

#include <bits/stdc++.h>
using namespace std;
const int sz=2e6+10, inf=1e9, mod=1e9+7;
int n, m=0, di[sz], st[sz], be[sz], good=0, add=0, i=0, an=1;
bool us[sz];
vector <int> dot[sz];
vector <pair <int, int> > cha[sz];
int lg, rg, va;
void ins(int nu, int l, int r)
{
    if(l>=lg and r<=rg) dot[nu].push_back(va);
    else if(!(l>rg or r<lg))
    {
        int mid=(l+r)>>1;
        ins(nu*2, l, mid);
        ins(nu*2+1, mid+1, r);
    }
}
void ins2(int x)
{
    if(st[x])
    {
        x--;
        while(x>1)
        {
            int cu=di[x], q=0;
            while(x%cu==0) x/=cu, q++;
            if(q>st[cu])
            {
                cha[i].push_back(make_pair(cu, st[cu]));
                st[cu]=q;
                if(st[cu]==be[cu]) good++;
            }
            if(us[cu])
            {
                cha[i].push_back({cu, -1}), us[cu]=0, ins2(cu);
            }
        }
    }
    else
    {
        cha[i].push_back({x, 0}), st[x]=1;
        if(st[x]==be[x]) good++;
        cha[i].push_back({x, -1}), us[x]=1;
    }
}
void build(int nu, int l, int r)
{
    for(int a=0; a<dot[nu].size(); a++)
    {
        int x=dot[nu][a];
        ins2(x);
        i++;
    }
    if(l==r)
    {
        if(good==m) add=1;
    }
    else
    {
        int mid=(l+r)>>1;
        build(nu*2, l, mid);
        build(nu*2+1, mid+1, r);
    }
    for(int a=0; a<dot[nu].size(); a++)
    {
        i--;
        while(cha[i].size())
        {
            int cu=cha[i].back().first, q=cha[i].back().second;
            if(q==-1) us[cu]^=1;
            else
            {
                if(st[cu]==be[cu]) good--;
                st[cu]=q;
            }
            cha[i].pop_back();
        }
    }
}
main()
{
    for(int a=2; a<sz; a++) di[a]=inf;
    for(int a=2; a<sz; a++)
    {
        if(di[a]==inf) for(int b=a; b<sz; b+=a) di[b]=min(di[b], a);
    }
    //freopen("input.txt", "r", stdin);
    int n;
    cin>>n;
    int ar[n];
    for(int a=0; a<n; a++) scanf("%d", &ar[a]);
    sort(ar, ar+n, greater <int>());
    for(int a=0; a<n; a++)
    {
        int x=ar[a];

        lg=0, rg=a-1, va=x;
        if(lg<=rg) ins(1, 0, n-1);

        lg=a+1, rg=n-1, va=x;
        if(lg<=rg) ins(1, 0, n-1);

        if(be[x]) x--;
        while(x>1)
        {
            int cu=di[x], q=0;
            while(x%cu==0) x/=cu, q++;
            be[cu]=max(be[cu], q);
        }
    }
    for(int a=0; a<sz; a++)
    {
        if(be[a])
        {
            m++;
            for(int b=0; b<be[a]; b++) an=(1ll*an*a)%mod;
        }
    }
    build(1, 0, n-1);
    an=(an+add)%mod;
    cout<<an;
}

#include<bits/stdc++.h>

using namespace std;

#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define sz(a) int((a).size())

#define x first
#define y second

typedef long long li;
typedef pair<int, int> pt;

const int MOD = int(1e9) + 7;

int mul(int a, int b) {
	return int(a * 1ll * b % MOD);
}

int binPow(int a, int k) {
	int ans = 1;
	while(k > 0) {
		if(k & 1) ans = mul(ans, a);
		a = mul(a, a);
		k >>= 1;
	}
	return ans;
}

const int M = 2000 * 1000 + 555;

int minD[M];
vector<pt> ps[M];

inline void precalc() {
	iota(minD, minD + M, 0);

	fore(val, 2, M) {
		if(minD[val] < val)
			continue;

		for(li j = val * 1ll * val; j < M; j += val)
			minD[j] = min(minD[j], val);
	}

	fore(i, 2, M) {
		int v = i;
		ps[i].clear();

		while(v > 1) {
			int md = minD[v];
			if(ps[i].empty() || ps[i].back().x != md)
				ps[i].emplace_back(md, 0);
			ps[i].back().y++;
			v /= md;
		}
	}
}

int n;
vector<int> p;

inline bool read() {
	if(!(cin >> n))
		return false;
	p.assign(n, 0);
	fore(i, 0, n)
		assert(scanf("%d", &p[i]) == 1);
	return true;
}

int a[M], cnt[M];

inline void solve() {
	sort(p.begin(), p.end(), greater<int>());

	for(int& cp : p) {
		if(a[cp] == 0) {
			a[cp] = 1;
			cnt[cp] = 1;
		} else {
			cp--;
			for(auto np : ps[cp]) {
				if(a[np.x] < np.y) {
					a[np.x] = np.y;
					cnt[np.x] = 1;
				} else if(a[np.x] == np.y)
					cnt[np.x]++;
			}
		}
	}

	int add = 0;
	for(int cp : p) {
		bool un = false;
		for(auto np : ps[cp])
			un |= (a[np.x] == np.y && cnt[np.x] == 1);
		if(!un)
			add = 1;
	}

	int lcm = 1;
	fore(i, 2, M)
		lcm = mul(lcm, binPow(i, a[i]));
	cout << (lcm + add) % MOD << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	int t = clock();
#endif
	cout << fixed << setprecision(10);

	precalc();
	if(read()) {
		solve();

#ifdef _DEBUG
		cerr << "TIME = " << clock() - t << endl;
#endif
	}
	return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cassert>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
using namespace std;

#define P 1000000007

int n, p[2100000], ma[2100000], cnt_ma[2100000];
int mark[2100000];
bool used[2100000], solid[2100000];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &p[i]);
	}
	sort(p + 1, p + n + 1);
	for (int i = n; i; i--) {
		if (i < n && p[i] == p[i + 1]) {
			mark[p[i] - 1]++;
		}else {
			bool uu = false;
			for (int j = p[i]; j <= 2000000; j += p[i])
				if (mark[j])
					uu = true;
			if (!uu) {
				mark[p[i]]++;
			}else {
				mark[p[i] - 1] ++;
			}
		}
	}
	int ans = 1;
	for (int i = 2; i <= 2000000; i++) {
		if (!used[i]) {
			for (int j = 2 * i; j <= 2000000; j += i)
				used[j] = true;
		}else {
			continue;
		}
		ma[i] = 0;
		for (int j = i; j <= 2000000; j += i)
			if (mark[j]) {
				int cnt = 0;
				int copy = j;
				while (copy % i == 0) {
					copy /= i;
					cnt ++;
				}
				if (cnt > ma[i]) {
					ma[i] = cnt;
					cnt_ma[i] = 1;
				}else if (cnt == ma[i]) {
					cnt_ma[i] ++;
				}
			}
		for (int j = i; j <= 2000000; j += i)
			if (mark[j]) {
				int cnt = 0;
				int copy = j;
				while (copy % i == 0) {
					copy /= i;
					cnt ++;
				}
				if (cnt == ma[i] && cnt_ma[i] == 1) {
					solid[j] = true;
				}
			}

		for (int j = 1; j <= ma[i]; j++) {
			ans = 1LL * ans * i % P;
		}
	}
	for (int i = 1; i <= 2000000; i++)
		if ((mark[i] > 0 && !solid[i]) || mark[i] > 1) {
			ans++;
			break;
		}
	printf("%d\n", ans % P);
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cassert>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<utility>
#include<bitset>
#include<complex>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<stack>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=a; i<=b; ++i)
#define PER(i,a,b) for(int i=a; i>=b; --i)
#define MP make_pair
#define PB push_back
#define fi first
#define se second
typedef long long LL;
typedef pair<int,int> pii;

const int maxn = 2e5;
const int maxP = 2e6;
const int P = 1e9+7;

inline LL PowMod(LL a, LL b) { LL r=1; while(b) { if(b&1) r=r*a%P; a=a*a%P, b>>=1; } return r; }

bool vis[maxP+5];
int mx1[maxP+5], mx2[maxP+5];
int prime[maxn+5], tot = 0;
void Pre() {
    prime[++tot] = 2;
    for(int i = 3; i <= maxP; i += 2) if(!vis[i]) {
        prime[++tot] = i;
        for(LL k = LL(i)*i; k <= maxP; k += i)
            vis[k] = 1;
    }
    //printf("tot = %d\n", tot);
}

int n, ai[maxn+5];
bool type[maxn+5];

inline void Upd(int a, int b) {
    if(mx1[a]<b) swap(mx1[a],b);
    if(mx2[a]<b) swap(mx2[a],b);
}

int main() {
    Pre();
    scanf("%d", &n);
    REP(i,1,n) scanf("%d", ai+i);
    sort(ai+1, ai+1+n);
    PER(i,n,1) {
        if(mx1[ai[i]] == 0) mx1[ai[i]] = 1;
        else {
            type[i] = 1;
            int val = ai[i]-1;
            for(int k = 1; k<=tot && prime[k]*prime[k]<=val; ++k) {
                int c = 0;
                while(val%prime[k]==0) ++c, val/=prime[k];
                Upd(prime[k], c);
            }
            if(val>1) Upd(val, 1);
        }
    }
    int del = 0;
    PER(i,n,1) {
        if(del) break;
        if(type[i] == 0) continue;
        bool fg = 1;
        int val = ai[i]-1;
        for(int k = 1; k<=tot && prime[k]*prime[k]<=val; ++k) {
            int c = 0;
            while(val%prime[k]==0) ++c, val/=prime[k];
            if(mx1[prime[k]]==c && mx2[prime[k]]!=c) {
                fg = 0; break;
            }
        }
        if(val>1 && (mx1[val]==1 && mx2[val]!=1)) fg = 0;
        del |= fg;
    }
    LL ans = 1;
    REP(i,1,maxP) if(mx1[i]) ans = ans * PowMod(i,mx1[i]) % P;
    printf("%lld\n", (ans+del) % P);
    return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e6+10;
const int mod=1e9+7;
int prime[N],pp,pri[N],ans=1,p[N],n,cnt[N],mx[N];
bool iscomp[N];
void primetable()
{
	for(int i=2;i<N;i++)
	{
		if(!iscomp[i])prime[pp++]=i,pri[i]=i;
		for(int j=0;j<pp&&1ll*i*prime[j]<N;j++)
		{
			iscomp[i*prime[j]]=1;
			pri[i*prime[j]]=prime[j];
			if(i%prime[j]==0)break;
		}
	}
}
int main()
{
	//freopen("in.txt","r",stdin);
	primetable();
	scanf("%d\n",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
    sort(p+1,p+n+1);
    for(int i=n;i;i--)
    {
    	if(!cnt[p[i]])cnt[p[i]]++,mx[p[i]]=1,ans=(1ll*ans*p[i])%mod;
    	else
    	{
    		int v=--p[i];
    		while(v!=1)
    		{
    			int u=pri[v],ci=0;
    			while(v%u==0)v/=u,ci++;
    			if(cnt[u]<ci)
    			{
    				for(int j=cnt[u]+1;j<=ci;j++)ans=(1ll*ans*u)%mod;
    				cnt[u]=ci;mx[u]=1;
				}
				else mx[u]+=(cnt[u]==ci);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		int v=p[i],flag=0;
		while(v!=1)
		{
			int u=pri[v],ci=0;
			while(v%u==0)v/=u,ci++;
			if(cnt[u]==ci&&mx[u]==1)flag=1;
		}
		if(!flag)
		{
			ans++;break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , __ = 2000007 , mo = 1000000007;

int isnp[__]={0},lasp[__]={0};

void fuck(int n=__-1)
{
	for(int i=2;i<=n;i++)
	{
		if(isnp[i])continue;
		lasp[i]=i;
		for(lint j=1ll*i*i;j<=n;j+=i)
		{
			isnp[j]=1;
			if(!lasp[j])lasp[j]=i;
		}
	}
}

map<int,pair<int,int>> mp;

void gmax(int who,int d)
{
	if(!who)return;
	if(mp[who].first<d)mp[who].second=0;
	if(mp[who].first<=d)mp[who].first=d,mp[who].second++;
}

void add(int x)
{
	int las=0,cnt=0;
	while(x>1)
	{
		int a=lasp[x];x/=a;
		if(las!=a)gmax(las,cnt),cnt=0;
		las=a,cnt++;
	}
	if(cnt)gmax(las,cnt);
}

int finder(int x)
{
	int las=0,cnt=0;
	while(x>1)
	{
		int a=lasp[x];x/=a;
		if(las!=a)
		{
			if(las && mp[las].first==cnt && mp[las].second==1)return 0;
			cnt=0;
		}
		las=a,cnt++;
	}
	if(las && mp[las].first==cnt && mp[las].second==1)return 0;
	return 1;
}

int n,val[_],fr[__]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	//freopen("i.in","r",stdin);

	fuck();

	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty();
	sort(val+1,val+n+1,greater<int>());

	for(int i=1,j=1;i<=n;i=j+1)
	{
		j=i;
		while(j<n && val[i]==val[j+1])j++;
		add(val[i]);
	}

	for(int i=1,j=1;i<=n;i=j+1)
	{
		j=i;
		while(j<n && val[i]==val[j+1])j++;
		int cnt=j-i+1;
		if(cnt+finder(val[i])>=2)
		{
			if(cnt==1)
			{
				fr[val[i]]=1;
				if(mp[val[i]].first==1)mp[val[i]].second--;
			}
			add(val[i]-1);
		}
	}

	int temp=0;
	for(int i=1,j=1;i<=n;i=j+1)
	{
		j=i;
		while(j<n && val[i]==val[j+1])j++;
		int cnt=j-i+1;
		if(cnt+(cnt==1?fr[val[i]]:finder(val[i]))+finder(val[i]-1)>=3)temp=1;
	}

	lint ans=1;
	for(auto i:mp)while(i.second.first--)ans=ans*i.first%mo;
	if(temp)ans=(ans+1)%mo;

	cout<<ans<<lf;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define N 2000010
#define mo 1000000007ll
#define int long long
int vi[N],c[N],pr[N],mx[N],v[N],ct,n,p[N];
void init(){
	for(int i=2;i<N;i++){
		if(!vi[i]){
			p[++ct]=i;
			pr[i]=i;
		}
		for(int j=1;j<=ct&&i*p[j]<N;j++){
			vi[i*p[j]]=1;
			pr[i*p[j]]=p[j];
			if(i%p[j]==0)break;
		}
	}
}
signed main(){
	init();
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>v[i];
	int r=1;
	sort(v+1,v+n+1);
	for(int i=n;i;i--){
		if(!c[v[i]]){
			c[v[i]]++;
			mx[v[i]]=1;
			r=r*v[i]%mo;
		}
		else{
			v[i]--;
			int x=v[i];
			while(x^1){
				int t=pr[x],ct=0;
				while(x%t==0){
					x/=t;
					ct++;
				}
				if(c[t]<ct){
					for(int j=c[t]+1;j<=ct;j++)
						r=(r*t)%mo;
					c[t]=ct;
					mx[t]=1;
				}
				else mx[t]+=(c[t]==ct);
			}
		}
	}
	for(int i=1;i<=n;i++){
		int x=v[i],ok=0;
		while(x^1){
			int t=pr[x],ct=0;
			while(x%t==0){
				x/=t;
				ct++;
			}
			if(c[t]==ct&&mx[t]==1)ok=1;
		}
		if(!ok){
			r++;
			break;
		}
	}
	cout<<r;
}

#include<cstdio>
const int MAX=2000010,mod=1000000007;
int n,m,mp[MAX],c[MAX],d[MAX],ds[MAX];
bool ty[MAX];
void upd(int i,int x){x>d[i]?d[i]=x,ds[i]=1:x==d[i]?ds[i]++:0;}
int main(){
	scanf("%d",&n);
	for(int p;n--;)scanf("%d",&p),c[p>m?m=p:p]++;
	for(int i=2;i<=m;i++)if(!mp[i])
		for(int j=i;j<=m;j+=i)if(!mp[j])mp[j]=i;
	int s=1,t=0;
	for(int i=m;i;i--)for(int j=c[i];j--;){
		if(d[i]){
			for(int x=i-1;x>1;){
				int p=mp[x],c=0;
				for(;x%p==0;x/=p)c++;
				for(int e=d[p];e<c;e++)s=1ll*s*p%mod;
				upd(p,c);
			}
			ty[i]=1;
		}
		else upd(i,1),s=1ll*s*i%mod;
	}
	for(int i=m;i;i--)if(ty[i]){
		bool fl=1;
		for(int x=i-1;x>1;){
			int p=mp[x],c=0;
			for(;x%p==0;x/=p)c++;
			if(c==d[p]&&ds[p]==1)fl=0;
		}
		if(fl)t=1;
	}
	printf("%d\n",(s+t)%mod);
}

#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
const int maxn=2e6,mod=1e9+7;
int n,a[222222],mx[2222222],can[2222222];
int cnt[2222222],cur[2222222],f,fl;
vector<int> v;
vector<pair<int,int> > g[2222222];
long long ans;
multiset<int> s[2222222];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=2;i<=maxn;i++)
	{
		if (mx[i]) continue;
		for (int j=i+i;j<=maxn;j+=i) mx[j]=i;
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for (int i=1;i<=n;i++)
	{
		if (cnt[a[i]])
		{
			a[i]--;
			v.clear();
			while(mx[a[i]])
			{
				int x=mx[a[i]];
				v.push_back(x);
				while(a[i]%x==0)
				{
					cur[x]++;
					a[i]/=x;
				}
			}
			if (a[i]>1)
			{
				v.push_back(a[i]);
				cur[a[i]]++;
			}
			for (int j=0;j<v.size();j++)
			{
				cnt[v[j]]=max(cnt[v[j]],cur[v[j]]);
				g[i].push_back(make_pair(v[j],cur[v[j]]));
				cur[v[j]]=0;
			}
		}
		else
		{
			cnt[a[i]]++;
			g[i].push_back(make_pair(a[i],1));
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<g[i].size();j++)
		{
			s[g[i][j].first].insert(g[i][j].second);
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<g[i].size();j++)
		{
			s[g[i][j].first].erase(s[g[i][j].first].find(g[i][j].second));
		}
		fl=0;
		for (int j=0;j<g[i].size();j++)
		{
			if (can[g[i][j].first]<g[i][j].second && (s[g[i][j].first].empty() || *s[g[i][j].first].rbegin()<g[i][j].second))
			{
				fl=1;
				break;
			}
		}
		if (!fl)
		{
			f=1;
			break;
		}
		for (int j=0;j<g[i].size();j++)
		{
			can[g[i][j].first]=max(can[g[i][j].first],g[i][j].second);
		}
	}
	ans=1;
	for (int i=2;i<=maxn;i++)
	{
		for (int j=1;j<=cnt[i];j++)
		{
			ans=ans*(long long)i%mod;
		}
	}
	ans=(ans+(long long)f)%mod;
	printf("%I64d\n",ans);
	return 0;
}

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=2e6+10;
const int mod=1e9+7;
int n,a[N],cnt[N],mx[N],ans=1,prime[N],val[N];
bool used[N];
void Lin_Sie(){
	used[1]=1;
	for(int i=2;i<N;i++){
		if(!used[i])prime[++prime[0]]=i,val[i]=i;
		for(int j=1;j<=prime[0]&&1ll*i*prime[j]<N;j++){
			used[i*prime[j]]=1;
			val[i*prime[j]]=prime[j];
			if(i%prime[j]==0)break;
		}
	}
}
int main()
{
	n=read();Lin_Sie();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
 	for(int i=n;i>=1;i--){
 		if(!cnt[a[i]])cnt[a[i]]++,mx[a[i]]=1,ans=(1ll*ans*a[i])%mod;
 		else{
 	    int v=--a[i];
 	    while(v!=1){
    		int u=val[v],ls=0;
    		while(v%u==0)v/=u,ls++;
    		if(cnt[u]<ls){
    			for(int j=cnt[u]+1;j<=ls;j++)ans=(1ll*ans*u)%mod;
    			cnt[u]=ls;mx[u]=1;
				}
				else if(cnt[u]==ls)mx[u]++;
 			}
 		}
 	}
	for(int i=1;i<=n;i++){
		int v=a[i],flag=0;
		while(v!=1){
			int u=val[v],ls=0;
			while(v%u==0)v/=u,ls++;
			if(cnt[u]==ls&&mx[u]==1)flag=1;
		}
		if(!flag){ans++;break;}
	}
	printf("%d\n",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 5;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline int fpow(int x, int k)
{
	int res = 1;
	while (k) {
		if (k & 1) res = (ll)res * x % mod;
		k >>= 1; x = (ll)x * x % mod;
	}
	return res;
}

int n, s, t;
int a[maxn], low[maxn], mx[maxn], num[maxn], vis[maxn];

void update(int p, int x) {if (x > mx[p]) mx[p] = x, num[p] = 1; else num[p] += mx[p] == x;}

int check(int x)
{
	for (int p, c; x > 1; ) {
		p = low[x]; c = 0;
		while (x % p == 0) x /= p, ++c;
		if (c == mx[p] && num[p] == 1) return 0;
	}
	return 1;
}

int main()
{
	n = gi(); s = 1;
	for (int i = 1; i <= n; ++i) a[i] = gi();
	sort(a + 1, a + n + 1);
	for (int i = 2; i <= a[n]; ++i)
		if (!low[i])
			for (int j = i; j <= a[n]; j += i)
				if (!low[j]) low[j] = i;

	for (int i = n, v, x, p, c; i; --i)
		if (mx[v = a[i]])
			for (vis[i] = 1, x = v - 1; x > 1; s = (ll)s * fpow(p, max(0, c - mx[p])) % mod, update(p, c)) {
				p = low[x]; c = 0;
				while (x % p == 0) x /= p, ++c;
			} else update(v, 1), s = (ll)s * v % mod;
	for (int i = 1; i <= n; ++i)
		if ((vis[i] && check(a[i] - 1)) || (!vis[i] && check(a[i]))) t = 1;
	printf("%d\n", (s + t) % mod);

	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int mo=1000000007;
const int M=2000005;
int n,x,a[M],b[M];
int mn[M],mx[M],t[M];
void init(){
	For(i,2,M-1) if (!mn[i])
		For(j,1,(M-1)/i) if (!mn[i*j])
			mn[i*j]=i;
}
void insert(int x){
	b[++*b]=x;
	for (;x!=1;){
		int v=mn[x],s=0;
		for (;x%v==0;x/=v,++s);
		if (s>mx[v]) mx[v]=s,t[v]=1;
		else if (s==mx[v]) t[v]++;
	}
}
bool check(int x){
	for (;x!=1;){
		int v=mn[x],s=0;
		for (;x%v==0;x/=v,++s);
		if (t[v]==1&&s==mx[v]) return 0;
	}
	return 1;
}
int main(){
	init();
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&x),++a[x];
	For(i,1,M-1) if (a[i]>=2)
		insert(i),insert(i-1);
	Rep(i,M-1,1) if (a[i]==1)
		insert(i-(mx[i]!=0));
	int ans1=1,ans2=0;
	For(i,1,M-1) For(j,1,mx[i])
		ans1=1ll*ans1*i%mo;
	For(i,2,M-1) if (a[i]>=3-(i==2)) ans2=1;
	For(i,1,*b) if (check(b[i])) ans2=1;
	printf("%d\n",(ans1+ans2)%mo);
}

#include<bits/stdc++.h>
#define ll long long
#define N 2000005
#define MOD 1000000007
using namespace std;
int n,p[N],f[N],pn,flag,d[N];
ll a[N],c[N],b[N];
ll pw(ll x,ll y){
	ll ans=1;
	for(;y;y>>=1,x=x*x%MOD)
	if (y&1) ans=ans*x%MOD;
	return ans;
}
void work(ll x){
	for (int i=1;i<=pn;i++){
		ll tmp=0;
		while(x%p[i]==0)x/=p[i],tmp++;
		if (c[i]==tmp) d[i]=2; else
		if (c[i]<tmp) c[i]=tmp,d[i]=1;
		if (x==1) break;
		if (f[x]>0){
			if (c[f[x]]==1) d[f[x]]=2; else
			if (c[f[x]]==0) c[f[x]]=1,d[f[x]]=1;
			break;
		}
	}
}
bool check(ll x){
	for (int i=1;i<=pn;i++){
		ll tmp=0;
		while(x%p[i]==0)x/=p[i],tmp++;
		if (c[i]==tmp&&d[i]==1) return 0;
		if (x==1) break;
		if (f[x]>0){
			if (c[f[x]]==1&&d[f[x]]==1) return 0;
			break;
		}
	}
	return 1;
}
int main(){
	flag=0;
	for (int i=2;i<=2000000;i++)
	if (f[i]==0){
		p[++pn]=i; f[i]=pn;
		for (int j=i+i;j<=2000000;j+=i) f[j]=-1;
	}
	//freopen("in.txt","r",stdin);
	//freopen("wa.txt","w",stdout);
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);

	for (int i=n;i>=1;i--){
		if (c[f[a[i]]]) work(a[i]-1),b[i]=a[i]-1;
		else work(a[i]),b[i]=a[i];
	}
	for (int i=1;i<=n&&!flag;i++)
	if (check(b[i])) flag=1;
	ll ans=1;
	for (int i=1;i<=pn;i++) ans=ans*pw(p[i],c[i])%MOD;
	printf("%lld\n",(ans+flag)%MOD);
}

//#pragma GCC optimize("O3")
//#pragma GCC target("arch=corei7-avx")
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
# include <sys/time.h>
# include <sys/resource.h>
#endif

/*** TEMPLATE CODE STARTS HERE ***/

#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795028841971693993751
#endif

using namespace std;

typedef vector<string> vs;
typedef long long ll;
typedef complex<double> pnt;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define RA(x) begin(x), end(x)
#define FE(i, x) for (auto i = begin(x); i != end(x); ++i)
#define SZ(x) ((ll) (x).size())

template<class T>
void splitstr(const string &s, vector<T> &out)
{
    istringstream in(s);
    out.clear();
    copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}

static void redirect(int argc, const char **argv)
{
#ifndef ONLINE_JUDGE
    struct rlimit rlim;
    getrlimit(RLIMIT_STACK, &rlim);
    rlim.rlim_cur = 256 * 1024 * 1024;
    setrlimit(RLIMIT_STACK, &rlim);
#ifndef __SANITIZE_ADDRESS__
    getrlimit(RLIMIT_DATA, &rlim);
    rlim.rlim_cur = 256 * 1024 * 1024;
    setrlimit(RLIMIT_DATA, &rlim);
#endif
#endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    if (argc > 1)
    {
        static filebuf f;
        f.open(argv[1], ios::in);
        cin.rdbuf(&f);
        if (!cin)
        {
            cerr << "Failed to open '" << argv[1] << "'" << endl;
            exit(1);
        }
    }

    if (argc > 2)
    {
        static filebuf f;
        f.open(argv[2], ios::out | ios::trunc);
        cout.rdbuf(&f);
        if (!cout)
        {
            cerr << "Failed to open '" << argv[2] << "'" << endl;
        }
    }
}

/*** TEMPLATE CODE ENDS HERE */

// Undefined sign for negative inputs
template<typename T> static constexpr T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> static constexpr T wrap_pos(T a, T m) { return a < 0 ? a + m : a; }
template<typename T> static constexpr T sqr(T a) { return a * a; }
// m must be positive
template<typename T> static constexpr T mod(T a, T m) { return wrap_pos(a % m, m); }

template<typename T>
static constexpr T inverse2(T a, T m) { return a <= 1 ? a : mod((1 - inverse2(m % a, a) * m) / a, m); }

// a must be relatively prime to m, m > 0
template<typename T>
static constexpr T inverse(T a, T m) { return inverse2(mod(a, m), m); }

template<typename T, typename P>
static constexpr T power(T a, P b) { return b == 0 ? T(1) : (b % 2) ? power(a, b - 1) * a : sqr(power(a, b / 2)); }

template<typename T, typename C, T Modulus>
class MR
{
private:
    struct tag_plus {}; // indicates value is in range [0, 2 * Modulus)
    struct tag_minus {}; // indicates value is in range (-Modulus, Modulus)
    struct tag_good {}; // indicates value is in range

    T value;

    static_assert(std::numeric_limits<C>::max() / Modulus / Modulus > 0, "compute type is too small");
    static_assert(Modulus < std::numeric_limits<T>::max() / 2, "storage type is too small");

    static constexpr T reduce(T value, tag_plus)
    {
        return value >= Modulus ? value - Modulus : value;
    }

    static constexpr T reduce(T value, tag_minus)
    {
        return value < 0 ? value + Modulus : value;
    }

    static constexpr T reduce(T value, tag_good) { return value; }

public:
    typedef T value_type;
    typedef C compute_type;
    static constexpr T modulus = Modulus;

    constexpr MR() : value(0) {}
    constexpr MR(C value) : value(reduce(value % Modulus, tag_minus())) {}
    template<typename tag_t>
    constexpr MR(T value, tag_t tag) : value(reduce(value, tag)) {}

    MR &operator=(C value) { this->value = reduce(value % Modulus, tag_minus()); return *this; }

    constexpr MR operator +(MR b) const { return MR(value + b.value, tag_plus()); }
    constexpr MR operator -(MR b) const { return MR(value - b.value, tag_minus()); }
    constexpr MR operator *(MR b) const { return MR(C(value) * C(b.value) % Modulus, tag_good()); }
    constexpr MR operator -() const { return MR(-value, tag_minus()); }

    MR &operator +=(MR b) { value = reduce(value + b.value, tag_plus()); return *this; }
    MR &operator -=(MR b) { value = reduce(value - b.value, tag_minus()); return *this; }
    MR &operator *=(MR b) { value = C(value) * C(b.value) % Modulus; return *this; }

    constexpr bool operator==(MR b) const { return value == b.value; }
    constexpr bool operator!=(MR b) const { return value != b.value; }

    constexpr T get() const { return value; }

    // These are only valid if the dividend is relatively prime to the modulus
    constexpr MR inverse() const
    {
        return MR(::inverse(C(value), C(Modulus)), tag_good());
    }
    constexpr MR operator /(MR b) const { return *this * b.inverse(); }
    MR &operator /=(MR b) { return *this *= b.inverse(); }
};

template<typename T, typename C, T Modulus>
static inline std::ostream &operator<<(std::ostream &o, MR<T, C, Modulus> mr)
{
    return o << mr.get();
}

typedef MR<int, ll, 1000000007> mr;

int main(int argc, const char **argv)
{
    redirect(argc, argv);
    vector<int> factor(2000001);
    for (int i = 2; i <= 2000000; i++)
        if (factor[i] == 0)
        {
            for (int j = i; j < SZ(factor); j += i)
                factor[j] = i;
        }
    int N;
    cin >> N;
    vi ps(N);
    for (int i = 0; i < N; i++)
        cin >> ps[i];
    sort(RA(ps), greater<int>());

    mr ans = 1;
    bool extra = false;
    unordered_map<int, pii> freq;
    vi more;
    for (int p : ps)
    {
        if (!freq.count(p))
        {
            freq[p] = pii(1, 1);
            ans *= p;
        }
        else
        {
            int x = p - 1;
            while (x > 1)
            {
                int f = factor[x];
                int r = 0;
                while (x % f == 0)
                {
                    x /= f;
                    r++;
                }
                auto &q = freq[f];
                if (r > q.first)
                {
                    for (int i = q.first; i < r; i++)
                        ans *= f;
                    q = pii(r, 1);
                }
                else if (r == q.first)
                    q.second++;
            }
            more.push_back(p);
        }
    }

    for (int p : more)
    {
        int x = p - 1;
        bool good = true;
        while (x > 1)
        {
            int f = factor[x];
            int r = 0;
            while (x % f == 0)
            {
                x /= f;
                r++;
            }
            pii q = freq[f];
            if (q.first == r && q.second <= 1)
            {
                good = false;
                break;
            }
        }
        if (good)
        {
            extra = true;
            break;
        }
    }

    if (extra)
        ans += 1;
    cout << ans << '\n';

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N=2e6+2;
const int mod=1e9+7;
int ar[N],uoc[N],cnt[N],pw[N];
bool haiz[N];
int mul(int x,int y){
	return (1ll*x*y)%mod;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,i,j,k,l,ok=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(i=2;i<N;i++){
		if(!uoc[i]){
			uoc[i]=i;
			for(j=i;j<N;j+=i){
				if(!uoc[j]){
					uoc[j]=i;
				}
			}
		}
	}
	sort(ar+1,ar+1+n);
	for(i=n;i>0;i--){
		if(!pw[ar[i]]){
			pw[ar[i]]=cnt[ar[i]]=1;
			haiz[i]=true;
		}
		else{
			if(ar[i]==2){
				ok=1;
			}
			else{
				j=ar[i]-1;
				while(j>1){
					k=uoc[j];
					l=0;
					while(j%k==0){
						j/=k;
						l++;
					}
					if(pw[k]<l){
						pw[k]=l;
						cnt[k]=0;
					}
					if(pw[k]==l){
						cnt[k]++;
					}
				}
			}
		}
	}
	for(i=n;i>0;i--){
		if(haiz[i]){
			continue;
		}
		if(ar[i]==2){
			ok=1;
		}
		else{
			bool cac=true;
			j=ar[i]-1;
			while(j>1){
				k=uoc[j];
				l=0;
				while(j%k==0){
					j/=k;
					l++;
				}
				if(pw[k]==l&&cnt[k]==1){
					cac=false;
					break;
				}
			}
			if(cac){
				ok=1;
			}
		}
	}
	k=1;
	for(i=1;i<N;i++){
		for(j=1;j<=pw[i];j++){
			k=mul(k,i);
		}
	}
	if(ok){
		k++;
		k%=mod;
	}
	cout<<k;
}

#include <iostream>
#include <ios>
#include <cstdint>
#include <vector>
#include <algorithm>

using ul = std::uint32_t;
using ull = std::uint64_t;
using li = std::int32_t;
using ll = std::int64_t;
using vull = std::vector<ull>;
using vul = std::vector<ul>;
using vvul = std::vector<vul>;

const ul base = 1e9 + 7;

vul datas(2e5);
ul n;
vul ans(2e6 + 1, 0);
vul cntans(2e6 + 1, 0);
vul primes;
vvul facts(2e6 + 1);
vvul factspow(2e6 + 1);

ul times(ul a, ul b) {
    return ull(a) * b % base;
}

ul pow(ul a, ul b) {
    if (b) {
        ul temp = pow(a, b >> 1);
        return (b & 1) ? times(temp, times(temp, a)) : times(temp, temp);
    } else {
        return ul(1);
    }
}

int main()
{
    std::cin >> n;
    datas.resize(n);
    for (ul i = 2; i <= 2e6; ++i) {
        if (facts[i].empty()) {
            primes.push_back(i);
            facts[i].push_back(i);
            factspow[i].push_back(1);
        }
        for (ul prime : primes) {
            ul j = i * prime;
            if (j > 2e6) {
                break;
            }
            if (i % prime) {
                facts[j].push_back(prime);
                factspow[j].push_back(1);
                for (ul k = 0; k != facts[i].size(); ++k) {
                    facts[j].push_back(facts[i][k]);
                    factspow[j].push_back(factspow[i][k]);
                }
            } else {
                facts[j] = facts[i];
                factspow[j] = factspow[i];
                ++factspow[j][0];
                break;
            }
        }
    }
    for (ul i = 0; i != n; ++i) {
        std::cin >> datas[i];
    }
    std::sort(datas.rbegin(), datas.rend());
    for (ul& p : datas) {
        if (ans[p]) {
            --p;
        }
        for (ul i = 0; i != facts[p].size(); ++i) {
            ul pr = facts[p][i];
            ul po = factspow[p][i];
            if (ans[pr] < po) {
                cntans[pr] = 1;
                ans[pr] = po;
            } else if (ans[pr] == po) {
                ++cntans[pr];
            }
        }
    }
    ul pp = 0;
    for (ul p : datas) {
        ul flag = 1;
        for (ul i = 0; i != facts[p].size(); ++i) {
            ul pr = facts[p][i];
            ul po = factspow[p][i];
            if (ans[pr] == po && cntans[pr] == 1) {
                flag = 0;
                break;
            }
        }
        if (flag == 1) {
            pp = 1;
            break;
        }
    }
    ul out = 1;
    for (ul i = 2; i != ans.size(); ++i) {
        out = times(out, pow(i, ans[i]));
    }
    std::cout << (out + pp < base ? out + pp : out + pp - base) << std::endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 2e6;
int main(int argc, char *argv[]) {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> primes;
	vector<int> lp(MAX + 1, 0);
	for(int i = 2; i <= MAX; i++) {
		if(not lp[i]) {
			lp[i] = i;
			primes.push_back(i);
		}
		for(auto p: primes) {
			if(p > lp[i] or i * p > MAX)
				break;
			lp[i * p] = p;
		}
	}
	vector<int> p(MAX + 1, 0);
	for(int i = 0; i < N; i++) {
		int t;
		cin >> t;
		p[t]++;
	}
	vector<int> q(MAX + 1, 0);
	vector<int> cnt(MAX + 1, 0);
	int TTT = 0;
	for(int i = MAX; i >= 1; i--) {
		if(p[i] >= 2) {
			if(q[i] < 1) {
				q[i] = 1;
				cnt[i] = 1;
			}
			else if(q[i] == 1)
				cnt[i]++;
			else
				TTT = 1;
			if(i == 2 || p[i] >= 3)
				TTT = 1;
			int t = i - 1;
			for(int lastp = lp[t], lpcnt = 0; t > 1; t /= lp[t]) {
				if(lastp == lp[t])
					lpcnt++;
				else {
					lastp = lp[t];
					lpcnt = 1;
				}
				if(q[lastp] < lpcnt) {
					q[lastp] = lpcnt;
					cnt[lastp] = 1;
				}
				else if(q[lastp] == lpcnt)
					cnt[lastp]++;
			}
		}
		else if(p[i] == 1) {
			if(q[i] == 0)
				q[i] = 1;
			else {
				if(i == 2)
					TTT = 1;
				int t = i - 1;
				for(int lastp = lp[t], lpcnt = 0; t > 1; t /= lp[t]) {
					if(lastp == lp[t])
						lpcnt++;
					else {
						lastp = lp[t];
						lpcnt = 1;
					}
					if(q[lastp] < lpcnt) {
						q[lastp] = lpcnt;
						cnt[lastp] = 1;
					}
					else if(q[lastp] == lpcnt)
						cnt[lastp]++;
				}
			}
		}
	}
	for(int i = MAX; i >= 1; i--) {
		if(p[i] >= 2 or (p[i] >= 1 and (q[i] > 1 or cnt[i] > 1))) {
			int t = i - 1;
			int ttt = 1;
			for(int lastp = lp[t], lpcnt = 0; t > 1; t /= lp[t]) {
				if(lastp == lp[t])
					lpcnt++;
				else {
					lastp = lp[t];
					lpcnt = 1;
				}
				if(q[lastp] == lpcnt and cnt[lastp] == 1)
					ttt = 0;
			}
			TTT |= ttt;
		}
	}
	int ans = 1;
	for(int i = 1; i <= MAX; i++)
		while(q[i]--)
			ans = ans * 1ll * i % MOD;
	cout << (ans + TTT) % MOD << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,C[2000005];
int go[2000005];
vector<int>cnt[2000005];
vector<P>vecc[600005];;
int main(){
	scanf("%d",&n);
	for(int i=2;i<=2000000;i++){
		if(go[i]) continue;
		go[i] = i;
		for(int j=i+i;j<=2000000;j+=i){
			go[j] = i;
		}
	}
	for(int i=1;i<=n;i++){
		int w;
		scanf("%d",&w);
		C[w]++;
	}
	int num = 0;
	bool ok = 0;
	for(int i=2000000;i>=2;i--){
		if(C[i] == 0) continue;
		if(C[i] == 1){
			if(cnt[i].empty()){
				cnt[i].pb(1);
				vecc[num++].pb(mp(i,1));
			}
			else{
				int cur = i-1;
    			vector<int>vec;
    			while(cur > 1){
    				vec.pb(go[cur]);
    				cur /= go[cur];
    			}
    			SORT(vec);
    			cur = -1;
    			int ccnt = 0;
    			for(int j=0;j<vec.size();j++){
    				if(j == 0){
    					cur = vec[j];
    					ccnt = 1;
    					continue;
    				}
    				if(cur != vec[j]){
    					cnt[cur].pb(ccnt);
    					vecc[num].pb(mp(cur,ccnt));
    					cur = vec[j];
    					ccnt = 1;
    				}
    				else ccnt++;
    			}
    			if(cur > 1){
        			cnt[cur].pb(ccnt);
        			vecc[num++].pb(mp(cur,ccnt));
    			}else num++;
			}
		}
		else {
			if(C[i] > 2) ok = 1;
			cnt[i].pb(1);
			vecc[num++].pb(mp(i,1));
			int cur = i-1;
			vector<int>vec;
			while(cur > 1){
				vec.pb(go[cur]);
				cur /= go[cur];
			}
			SORT(vec);
			cur = -1;
			int ccnt = 0;
			for(int j=0;j<vec.size();j++){
				if(j == 0){
					cur = vec[j];
					ccnt = 1;
					continue;
				}
				if(cur != vec[j]){
					cnt[cur].pb(ccnt);
					vecc[num].pb(mp(cur,ccnt));
					cur = vec[j];
					ccnt = 1;
				}
				else ccnt++;
			}
			if(cur > 1){
    			cnt[cur].pb(ccnt);
    			vecc[num++].pb(mp(cur,ccnt));
			}else num++;
		}
	}
	for(int i=2;i<=2000000;i++){
		SORT(cnt[i]);
		reverse(cnt[i].begin(),cnt[i].end());
	}
	for(int i=0;i<num;i++){
		for(int j=0;j<vecc[i].size();j++){
			int A = vecc[i][j].fi, B = vecc[i][j].sc;
			if(cnt[A].size() == 1 || cnt[A][1] < B) goto fail;
		}
		ok = 1; break;
		fail:;
	}
	ll ans = 1;
	for(int i=2;i<=2000000;i++){
		if(cnt[i].size()) rep(j,cnt[i][0]) ans = ans*1LL*i%mod;
	}
	if(ok) ans = (ans+1LL)%mod;
	cout<<ans<<endl;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 3e6;
const int MOD = 1e9 + 7;
int n, res = 1, mx, ct[N], cs[N], imp[N], ff;
int not_prime[N];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i)
    {
        int a;
        scanf("%d", &a);
        mx = max(mx, a);
        ct[a] ++;
    }
    for (int i = mx; i >= 1; -- i) if (ct[i])
    {
        int gg = 0;
        for (int j = i + i; j <= mx; j += i)
            if (cs[j]) gg = 1;
        if (!gg) cs[i] = 1, ct[i] --;
        cs[i - 1] += ct[i];
    }
    for (int i = 2; i <= mx; ++ i)
        if (!not_prime[i])
        {
            for (int j = i + i; j <= mx; j += i)
                not_prime[j] = 1;
            int q = 0, c = 0;
            for (int j = i; j <= mx; j += i)
                if (cs[j])
                {
                    int k = j, p = 0;
                    while (k % i == 0) k /= i, p ++;
                    if (p > q) q = p, c = cs[j];
                    else if (p == q) c += cs[j];
                }
            for (int j = i; j <= mx; j += i)
                if (cs[j])
                {
                    int k = j, p = 0;
                    while (k % i == 0) k /= i, p ++;
                    if (p == q && c == 1) imp[j] = 1;
                }
            while (q --) res = 1ll * res * i % MOD;
        }
    for (int i = 1; i <= mx; ++ i)
        if (cs[i] && !imp[i]) ff = 1;
    res = (res + ff) % MOD;
    printf("%d\n", res);
}

//Konrad Paluszek, University of Warsaw (former XIV LO Warsaw)
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template <class c
#define mor > muu & operator<< (
#define ris return *this
#define R22(r) sim> typename enable_if<1 r sizeof(dud<c>(0)), muu&>::type operator<<(c g) {
sim> struct rge {c h, n;};
sim> rge<c> range(c h, c n) {return rge<c>{h, n};}
sim, class F> struct rgm {c h, n; F f;};
sim, class F> rgm<c, F> map_range(c b, c e, F f) {return rgm<c, F>{b, e, f};}
sim, class F> rgm<typename c::const_iterator, F> map_range(const c &x, F f) {return map_range(x.begin(), x.end(), f);}
sim> auto dud(c *r) -> decltype(cerr << *r);
sim> char dud(...);
struct muu {
#ifdef LOCAL
	stringstream a;
	~muu() {cerr << a.str() << endl;}
	R22(<) a << boolalpha << g; ris;}
	R22(==) ris << range(begin(g), end(g));}
	sim mor rge<c> u) {
		a << '{';
		for (c s = u.h; s != u.n; ++s)
			*this << ", " + 2 * (s == u.h) << *s;
		ris << '}';
	}
	sim, class n mor pair <c,n> r) {ris << "(" << r.first << ", " << r.second << ")";}
	sim, class F mor rgm<c, F> u) {
		for (c s = u.h; s != u.n; ++s)
			u.f(*this << ", " + 2 * (s == u.h), *s);
		ris;
	}
	#else
	sim mor const c&) {ris;}
	#endif
	muu & operator()() {ris;}
};
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")
#define imie(r) "[" #r ": " << (r) << "] "
#define imask(r) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) << ": " << a[i][j] << "] "
#define div __div__ejJ46
#define exp __exP__QkL47
const int nax = 2e6 + 44, mod = 1e9 + 7;
int div[nax];
pair <int, int> exp[nax];
int primes[nax];
void add(int p, int e) {
	if (exp[p].first < e)
		exp[p] = make_pair(e, 1);
	else if (exp[p].first == e)
		exp[p].second++;
}
int main() {
	for (int p = 2; p < nax; ++p)
		if (div[p] == 0)
			for (int k = p; k < nax; k += p)
				div[k] = p;
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", primes + i);
	sort(primes, primes + n, greater<int>());
	vector <int> used;
	for (int i = 0; i < n; ++i) {
		debug << arr(primes, i);
		if (exp[primes[i]].first == 0) {
			used.push_back(primes[i]);
			add(primes[i], 1);
		}
		else {
			int fac = primes[i] - 1;
			used.push_back(fac);
			while (fac > 1) {
				int p = div[fac];
				int e = 0;
				while (fac % p == 0) {
					fac /= p;
					e++;
				}
				add(p, e);
			}
		}
	}
	debug << imie(used);
	bool add = false;
	for (int x : used) {
		bool full = true;
		int xx = x;
		while (xx > 1) {
			int p = div[xx];
			int e = 0;
			while (xx % p == 0) {
				xx /= p;
				e++;
			}
			if (exp[p].first == e && exp[p].second < 2) {
				debug << imie(x) " failed on " arr(exp, p) imie(e);
				full = false;
			}
		}
		if (full) {
			debug << imie(x) << "is full";
			add = true;
		}
	}
	long long ans = 1;
	for (int i = 1; i < nax; ++i)
		for (int k = 0; k < exp[i].first; ++k)
			ans = ans * i % mod;
	if (add)
		ans++;
	ans %= mod;
	printf("%lld\n", ans);
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    vector<int> used(n, 0);

    vector<vector<pair<int,int> > > pfact(n);

    map<int,int> f;
    map<int,int> ffreq;

    for(int i = 0; i < n; i++){
        if(f[a[i]] == 0){
            f[a[i]] = 1;
            used[i] = 1;
            ffreq[a[i]] = 1;
        } else {
            a[i]--;
            for(int p = 2; p * p <= a[i]; p++){
                if(a[i] % p == 0){
                    int k = 0;
                    while(a[i] % p == 0){
                        a[i] /= p;
                        k++;
                    }
                    pfact[i].push_back({p, k});
                    if(k > f[p]){
                        f[p] = k;
                        ffreq[p] = 0;
                    }
                    if(k == f[p]){
                        ffreq[p]++;
                    }
                }
            }
            if(a[i] > 1){
                int p = a[i];
                int k = 1;
                pfact[i].push_back({p, k});
                if(k > f[p]){
                    f[p] = k;
                    ffreq[p] = 0;
                }
                if(k == f[p]){
                    ffreq[p]++;
                }
            }
        }
    }
    const LL MOD = 1000000007;
    LL num = 1;
    for(auto x : f){
        for(int j = 0; j < x.second; j++){
            num = (num * (LL) x.first) % MOD;
        }
    }
    int ok = 0;
    for(int i = 0; i < n; i++){
        if(!used[i]){
            int can_delete = 1;
            for(pair<int,int> x : pfact[i]){
                int p = x.first;
                int k = x.second;
                if(f[p] == k && ffreq[p] == 1){
                    can_delete = 0;
                }
            }
            if(can_delete == 1) ok = 1;
        }
    }
    num = (num + ok) % MOD;
    cout << num << '\n';
}

/*
_____
.'     '.
/  0   0  \
|     ^     |
|  \     /  |
\  '---'  /
'._____.'
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

struct chash
{
	int operator()(int x) const
	{
		x ^= (x >> 20) ^ (x >> 12);
		return x ^ (x >> 7) ^ (x >> 4);
	}
};

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename U> using hashtable = gp_hash_table<T, U, chash>;
random_device(rd);
mt19937 rng(rd());

template<class T>
void readi(T &x)
{
	T input = 0;
	bool negative = false;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = input * 10 + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	x = input;
}
template<class T>
void printi(T output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
template<class T>
void ckmin(T &a, T b)
{
	a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
	a = max(a, b);
}
template<class T, class U>
T nmod(T &x, U mod)
{
	if (x >= mod) x -= mod;
}
template<class T>
T gcd(T a, T b)
{
	return (b ? gcd(b, a % b) : a);
}
template<class T>
T randomize(T mod)
{
	return (uniform_int_distribution<T>(0, mod - 1))(rng);
}

#define y0 ___y0
#define y1 ___y1
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << x << endl;

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-10;

#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
#define MAXN 2000013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

int N;
int sp[MAXN];
vector<int> primes;
int freq[MAXN];
int dp[MAXN], fk[MAXN];
bool one;
ll ans = 1;

vector<pii> factorize(int x)
{
	vector<pii> res;
	while(x > 1)
	{
		int p = sp[x];
		if (res.empty() || p != res.back().fi)
		{
			res.PB({p, 1});
		}
		else
		{
			res.back().se++;
		}
		x /= p;
	}
	return res;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	// cout << fixed << setprecision(10);
	// cerr << fixed << setprecision(10);
	// freopen ("file.in", "r", stdin);
	// freopen ("file.out", "w", stdout);
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		freq[x]++;
	}
	for (int i = 2; i < MAXN; i++)
	{
		if (sp[i] == 0)
		{
			sp[i] = i;
			primes.PB(i);
		}
		for (int p : primes)
		{
			if (p > sp[i] || i * p >= MAXN)
			{
				break;
			}
			sp[i * p] = p;
		}
	}
	// cerr << "blah\n";
	for (int i = MAXN - 1; i >= 2; i--)
	{
		if (freq[i] == 0)
		{
			continue;
		}
		if (dp[i] == 0)
		{
			freq[i]--;
			dp[i] = 1;
		}
		if (freq[i] == 0)
		{
			continue;
		}
		vector<pii> vec = factorize(i - 1);
		for (pii p : vec)
		{
			if (p.se > dp[p.fi])
			{
				dp[p.fi] = p.se;
				fk[p.fi] = 1;
			}
			else if (p.se == dp[p.fi])
			{
				fk[p.fi]++;
			}
		}
		if (freq[i] > 1)
		{
			one = true;
		}
	}
	for (int i = MAXN - 1; i >= 2; i--)
	{
		for (int j = 0; j < dp[i]; j++)
		{
			ans *= i;
			ans %= INF;
		}
		if (freq[i] == 0 || one)
		{
			continue;
		}
		bool newd = true;
		vector<pii> vec = factorize(i - 1);
		for (pii p : vec)
		{
			if (p.se == dp[p.fi] && fk[p.fi] == 1)
			{
				newd = false;
			}
		}
		one |= newd;
	}
	if (one)
	{
		ans++;
		nmod(ans, INF);
	}
	cout << ans << '\n';
	// cerr << "time elapsed = " << (clock() / (CLOCKS_PER_SEC / 1000)) << " ms" << endl;
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long LL;
const int N = 2e6 + 50;
const LL mod = 1e9 + 7;

inline LL Pow(LL x, LL exp) {
  LL res = 1;
  for (; exp; exp >>= 1, x = x * x % mod)
    if (exp & 1) res = res * x % mod;
  return res;
}

int pri[N / 3], m;
bool notp[N];
vector <int> divi[N];

inline void Init() {
  for (int i = 2; i < N; i ++)
    divi[i].reserve(8);
  for (int i = 2; i < N; i ++)
    if (!notp[i]) {
      pri[++ m] = i;
      divi[i].push_back(i);
      for (int j = i + i; j < N; j += i) {
        notp[j] = 1;
        divi[j].push_back(i);
      }
    }
}

int n, a[N], cnt[N], num[N], state[N];

inline void Insert(int x) {
  int t = x;
  for (auto i : divi[x]) {
    int c = 0;
    while (t % i == 0) {
      t /= i; c ++;
    }
    if (cnt[i] < c) cnt[i] = c, num[i] = 1;
    else if (cnt[i] == c) num[i] ++;
  }
}

inline bool check(int x) {
  int t = x;
  for (auto i : divi[x]) {
    int c = 0;
    while (t % i == 0) {
      t /= i; c ++;
    }
    if (cnt[i] == c && num[i] == 1) return 0;
  }
  return 1;
}

int main() {
  Init();
  scanf("%d", &n);
  for (int i = 1, x; i <= n; i ++) {
    scanf("%d", &x); a[x] ++;
  }
  bool add = 0;
  for (int i = 1; i < N; i ++) {
    if (a[i] > 2) add = 1;
    if (a[i] >= 2) {
      Insert(i); Insert(i - 1);
      state[i] = 3;
    }
  }
  for (int i = N - 1; i; i --)
    if (a[i] == 1) {
      if (cnt[i]) Insert(i - 1), state[i] = 1;
      else Insert(i), state[i] = 2;
    }
  for (int i = 1; i < N && !add; i ++) {
    if (state[i] & 1) add |= check(i - 1);
    if (state[i] & 2) add |= check(i);
  }
  LL ans = 1;
  for (int i = 2; i < N; i ++)
    if (cnt[i]) ans = ans * Pow(i, cnt[i]) % mod;
  printf("%lld\n", (ans + add) % mod);
  return 0;
}
//ThIS coDe iS suBmItted by ojsubmiTter DEvelopED By sImpHoni.

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int N=2e6+1;
const LL M=1e9+7;

int n,a[N],f[N],cnt[N];
vector<pii> fac[N];
bool used[N],vis[N];

void init() {
	for(int i=2;i<N;i++) {
		if(vis[i]) continue;
		fac[i].push_back(pii(i,1));
		for(int j=i+i;j<N;j+=i) {
			vis[j]=1;
			if(used[j]) {
				int c=0,x=j;
				while(x%i==0) {
					c++;x/=i;
				}
				fac[j].push_back(pii(i,c));
			}
		}
	}
}

int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		used[a[i]-1]=1;
	}
	init();

	sort(a,a+n);
	for(int i=n-1;i>=0;i--) {
		int x=a[i];
		if(f[x]) a[i]=--x;
		for(int j=0;j<fac[x].size();j++) {
			pii p=fac[x][j];
			int y=p.first;
			if(p.second>f[y]) f[y]=p.second,cnt[y]=1;
			else if(p.second==f[y]) cnt[y]++;
		}
	}

	bool ok=0;
	for(int i=0;i<n;i++) {
		int x=a[i];
		bool g=1;
		for(int j=0;j<fac[x].size();j++) {
			pii p=fac[x][j];
			int y=p.first;
			if(p.second==f[y] && cnt[y]==1) {
				g=0;break;
			}
		}
		if(g) {
			ok=1;break;
		}
	}

	LL ans=1;
	for(int i=2;i<N;i++) {
		while(f[i]) {
			ans=ans*i%M;
			f[i]--;
		}
	}
	if(ok) ans++,ans%=M;
	printf("%lld\n",ans);
}

#include <bits/stdc++.h>
using namespace std;
#define forsn(i,s,n) for(int i = int(s);i<int(n);i++)
#define dforsn(i,s,n) for(int i = int(n)-1;i>=int(s);i--)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) dforsn(i,0,n)
#define DBG(x) do{cout<<#x<<" = "<<x<<endl;}while(false)
typedef long long intl;
typedef long long ll;
#define MAXN   2000001
int spf[MAXN];
void sieve() {
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        spf[i] = i;
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++) {
        if (spf[i] == i) {
            for (int j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<pair<int,int>> getFactorization(int x) {
    vector<pair<int,int>> ret;
	int last=1;
	int count=1;
    while (x != 1) {
    	if(last!=spf[x]){
    		if(last!=1){
    			ret.push_back({last,count});
			}
			count=1;
			last=spf[x];
		}
		else{
			count++;
		}
        x = x / spf[x];
    }
    if(last!=1){
       ret.push_back({last,count});
	}
    return ret;
}
intl MOD=1e9+7;
intl fst(intl x,intl e){
	intl ans=1;
	while(e>0){
		if(e%2==1){
			ans*=x;
			ans=ans%MOD;
		}
		x*=x;
		x=x%MOD;
		e/=2;
	}
	return ans;
}
int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);
    sieve();
   	int n;
   	cin>>n;
   	map <int,int> factors;
   	map<int,int> many;
   	vector <int> visited(MAXN,0);
   	intl sum=0;
   	vector <int> orig;
   	for(int i=0;i<n;i++){
   		int a;
   		cin>>a;
   		orig.push_back(a);
	}
	sort(orig.begin(),orig.end());
	reverse(orig.begin(),orig.end());
   	for(int i=0;i<n;i++){
   		int a=orig[i];
		if(visited[a]){
			vector<pair<int,int> >  v=getFactorization(a-1);
			for(auto x:v){
				if(!factors.count(x.first)){
					factors[x.first]=x.second;
					many[x.first]=0;
				}
				if(factors[x.first]<x.second){
					factors[x.first]=x.second;
					many[x.first]=1;
				}
				else if(factors[x.first]==x.second){
					many[x.first]++;
				}
				visited[x.first]++;
			}
		}
		else{
			vector<pair<int,int> > v=getFactorization(a);
			for(auto x:v){
				if(!factors.count(x.first)){
					factors[x.first]=x.second;
					many[x.first]=0;
				}
				if(factors[x.first]<x.second){
					factors[x.first]=x.second;
					many[x.first]=1;
				}
				else if(factors[x.first]==x.second){
					many[x.first]++;
				}

			}
		}
		visited[a]++;
	}
	vector <int> visited1(MAXN,0);
	for(int i=0;i<n;i++){
		int a=orig[i];
		bool nopuedo=false;
		if(visited1[a]){
			vector<pair<int,int> >  v=getFactorization(a-1);
			for(auto x:v){
				//cout<<factors[x.first]<<" "<<x.first<<" "<<x.second<<" "<<many[x.first]<<endl;
				if(factors[x.first]==x.second && many[x.first]==1){
					nopuedo=true;
				}
				visited1[x.first]++;
			}
		}
		else{
			vector<pair<int,int> > v=getFactorization(a);
			for(auto x:v){
				if(factors[x.first]==x.second && many[x.first]==1){
					nopuedo=true;
				}

			}

		}
		visited1[a]++;
		if(!nopuedo){
			sum=1;
		}
	}
	intl ans=1;
	for(auto x:factors){
		ans*=fst(intl(x.first),intl(x.second));
		ans=ans%MOD;
	}
	cout<<(ans+sum)%MOD<<endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=5000005,P=1e9+7;
int n,pr[maxn],mp[maxn];
bool vis[maxn];
void getP(int n){
  for(int i=2;i<=n;i++){
    if(!vis[i]) pr[++pr[0]]=i, mp[i]=i;
    for(int j=1;j<=pr[0]&&i*pr[j]<=n;j++){
      vis[i*pr[j]]=true; mp[i*pr[j]]=pr[j];
      if(i%pr[j]==0) break;
    }
  }
}
int mx[maxn],cnt[maxn],p[maxn];
LL ans=1;
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&p[i]);
  sort(p+1,p+1+n); getP(p[n]);
  for(int i=n;i>=1;i--){
    if(!mx[p[i]]) mx[p[i]]=1, cnt[p[i]]=1, ans=ans*p[i]%P;
    else{
      int t=--p[i];
      while(t>1){
	int d=mp[t],k=0;
	while(t%d==0) k++, t/=d;
	if(mx[d]<k){
	  for(int j=mx[d]+1;j<=k;j++) ans=ans*d%P;
	  mx[d]=k; cnt[d]=1;
	} else cnt[d]+=(k==mx[d]);
      }
    }
  }
  for(int i=1;i<=n;i++){
    bool pd=false;
    int t=p[i];
    while(t>1){
      int d=mp[t],k=0;
      while(t%d==0) k++, t/=d;
      if(mx[d]==k&&cnt[d]==1) pd=true;
    }
    if(!pd){ ans=(ans+1)%P; break; }
  }
  printf("%lld\n",ans);
}

#include<bits/stdc++.h>
#define LL long long
#define db long double
#define short int

using namespace std;
const int N=2e6+10,mod=1e9+7;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int prm[N],pm[N],tt,n,a[N],c[N][2];
bool v[N];

int main()
{
    for(int i=2;i<=N-5;++i)
    {
	if(!pm[i]) pm[i]=prm[++tt]=i;
	for(int j=1;i*prm[j]<=N-5;++j)
	{
	    pm[i*prm[j]]=prm[j];
	    if(i%prm[j]==0) break;
	}
    }
    n=rd();
    for(int i=1;i<=n;++i) a[i]=rd();
    sort(a+1,a+n+1),reverse(a+1,a+n+1);
    for(int i=1;i<=n;++i)
    {
	if(!c[a[i]][0]) v[i]=1,c[a[i]][0]=c[a[i]][1]=1;
	else
	{
	    int x=a[i]-1;
	    while(x>1)
	    {
		int np=pm[x],cn=0;
		while(pm[x]==np) ++cn,x/=np;
		if(c[np][0]<cn) c[np][0]=cn,c[np][1]=1;
		else c[np][1]+=c[np][0]==cn;
	    }
	}
    }
    int ans=1;
    for(int i=2;i<=N-5;++i)
	for(int j=1;j<=c[i][0];++j)
	    ans=1ll*ans*i%mod;
    for(int i=1;i<=n;++i)
	if(!v[i])
	{
	    int x=a[i]-1,o=1;
	    while(x>1)
	    {
		int np=pm[x],cn=0;
		while(pm[x]==np) ++cn,x/=np;
		o&=cn<c[np][0]||c[np][1]>1;
	    }
	    if(o){ans=(ans+o)%mod;break;}
	}
    printf("%d\n",ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int mxN=2e5, mxA=2e6, M=1e9+7;
int n, p[mxN], spf[mxA+1];
vector<int> pfs;
array<int, 2> a[mxA+1];
bool c[mxN];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	for(int i=2; i<=mxA; ++i) {
		if(!spf[i]) {
			pfs.push_back(i);
			spf[i]=i;
		}
		for(int j=0; j<pfs.size()&&pfs[j]<=spf[i]&&i*pfs[j]<=mxA; ++j)
			spf[i*pfs[j]]=pfs[j];
	}
	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> p[i];
	sort(p, p+n, greater<int>());
	for(int i=0; i<n; ++i) {
		c[i]=a[p[i]][0];
		int b=c[i]?p[i]-1:p[i];
		while(spf[b]) {
			int c=spf[b], d=0;
			while(b%c==0) {
				b/=c;
				++d;
			}
			if(a[c][0]<d)
				a[c]={d};
			if(a[c][0]==d)
				++a[c][1];
		}
	}
	long long ans=1;
	for(int i=2; i<=mxA; ++i)
		for(int j=0; j<a[i][0]; ++j)
			ans=i*ans%M;
	for(int i=0; i<n; ++i) {
		if(!c[i])
			continue;
		int b=p[i]-1;
		bool ok=1;
		while(spf[b]&&ok) {
			int c=spf[b], d=0;
			while(b%c==0) {
				b/=c;
				++d;
			}
			ok=a[c]>array<int, 2>{d, 1};
		}
		if(ok) {
			++ans;
			break;
		}
	}
	cout << ans;
}

#pragma GCC optimize "-O3"
#include<bits/stdc++.h>

using namespace std;

const int   N   = 2e6 + 1;
const int   mod = 1e9 + 7;

vector<int> pr[N];

void sieve()    {
    for(int i = 2 ; i < N ; ++i)
        if (pr[i].empty())  {
            for(int j = i ; j < N ; j += i)
                pr[j].push_back(i);
        }
}

int n, p[N];
int e[N];
int  cnt[N];
bool sub[N];

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    sieve();
    cin >> n;

    for(int i = 1 ; i <= n ; ++i)   cin >> p[i];

    sort(p + 1,p + 1 + n,greater<int>());

    int Profit = 0;

    for(int i = 1 ; i <= n ; ++i)   {
        if(!e[p[i]])    {
            e[p[i]] = 1;
            continue;
        }
        bool ch = 1;
        sub[i]  = 1;
        int Ori = p[i] - 1;
        for(int x : pr[p[i] - 1])   {
            int exp = 0;
            while(!(Ori % x))   ++exp, Ori /= x;
            if (exp > e[x]) {
                e[x] = exp;
                ch = 0;
                cnt[x] = 0;
            }
            if (exp == e[x])
                ++cnt[x];
        }
        Profit = max(Profit,(int)ch);
    }

    if (!Profit)    {
        for(int i = 1 ; i <= n ; ++i)   {
            int Ori = p[i] - sub[i];
            bool ch = 1;
            for(int x : pr[Ori])    {
                int exp = 0;
                while(!(Ori % x))   ++exp, Ori /= x;
                ch &= (exp < e[x] || cnt[x] > 1);
            }
            Profit = max(Profit,(int)ch);
        }
    }

    long long ans = 1;

    for(int i = 2 ; i < N ; ++i)
        while(e[i]--)
            ans = 1ll * ans * i % mod;

    ans = (ans + Profit) % mod;

    cout << ans << endl;
}

#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

const int MOD = 1e9 + 7;
const int P_MAX = 2e6 + 5;

vector<int> smallest_factor;
vector<bool> prime;

void sieve(int maximum) {
    assert(maximum > 0);
    smallest_factor.assign(maximum + 1, 0);
    prime.assign(maximum + 1, true);
    prime[0] = prime[1] = false;

    for (int p = 2; p <= maximum; p += 2) {
        prime[p] = p == 2;
        smallest_factor[p] = 2;
    }

    for (int p = 3; p * p <= maximum; p += 2)
        if (prime[p])
            for (int i = p * p; i <= maximum; i += 2 * p)
                if (prime[i]) {
                    prime[i] = false;
                    smallest_factor[i] = p;
                }

    for (int p = 2; p <= maximum; p++)
        if (prime[p])
            smallest_factor[p] = p;
}

int N;
vector<int> P;
vector<int> powers(P_MAX, 0);
vector<int> reach_count(P_MAX, 0);

bool add(int number, bool real = true) {
    bool helpful = false;

    while (number > 1) {
        int p = smallest_factor[number];
        int power = 0;

        do {
            number /= p;
            power++;
        } while (number % p == 0);

        if (!real) {
            helpful = helpful || power > powers[p];
            continue;
        }

        if (power > powers[p]) {
            powers[p] = power;
            helpful = true;
            reach_count[p] = 1;
        } else if (power == powers[p]) {
            reach_count[p]++;
        }
    }

    return helpful;
}

bool removable(int number) {
    bool ok = true;

    while (number > 1) {
        int p = smallest_factor[number];
        int power = 0;

        do {
            number /= p;
            power++;
        } while (number % p == 0);

        if (power == powers[p] && reach_count[p] == 1)
            ok = false;
    }

    return ok;
}

int main() {
    sieve(P_MAX);
    scanf("%d", &N);
    P.resize(N);
    map<int, int> P_freq;

    for (int i = 0; i < N; i++) {
        scanf("%d", &P[i]);
        P_freq[P[i]]++;
    }

    for (auto it = P_freq.rbegin(); it != P_freq.rend(); it++)
        for (int k = 0; k < it->second; k++)
            if (add(it->first, false))
                add(it->first);
            else
                add(it->first - 1);

    bool add_one = false;

    for (auto it = P_freq.rbegin(); it != P_freq.rend(); it++)
        if (it->second >= 2 && removable(it->first - 1))
            add_one = true;

    long long answer = 1;

    for (int i = 2; i < P_MAX; i++)
        for (int j = 0; j < powers[i]; j++)
            answer = answer * i % MOD;

    if (add_one)
        answer = (answer + 1) % MOD;

    printf("%lld\n", answer);
}

#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
#define NN 2000010
int prime[NN];
int flag[NN];
int vst[NN];
int cnt[NN];
int p[NN];
int r[NN];
int s[NN];
int num[NN];
int np;
int pp[NN];
void prepare(){
	for(int i=2;i<NN;i++){
		if(!flag[i]){
			prime[np++]=i;
			flag[i]=i;
		}
		for(int j=0;j<np&&prime[j]*i<NN;j++){
			flag[i*prime[j]]=prime[j];
			if(flag[i]==prime[j]) break;
		}
	}
}
int power(int a, int b, int m, int ans=1) {
    for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;
    return ans;
}
bool cmp(int u,int v){
	return u>v;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	prepare();
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		cnt[p[i]]++;
	}
  	sort(p+1,p+n+1,cmp);
  	n=unique(p+1,p+n+1)-p-1;
  	int Flag=0,m=0;
  	for(int i=1;i<=n;i++){
  		if(!Flag){
			if(cnt[p[i]]>2||(cnt[p[i]]==2&&vst[p[i]]==1)) Flag=1;
			if(!Flag){
				if(cnt[p[i]]==1&&vst[p[i]]==1) pp[m++]=p[i];
				if(cnt[p[i]]==2&&vst[p[i]]==0) pp[m++]=p[i];
			}
		}
  		if(!vst[p[i]]) r[p[i]]++;
		if(cnt[p[i]]>1||vst[p[i]]){
			int st=p[i]-1;
			while(st>1){
				int q=flag[st];
				vst[q]=1;
				int t=0;
				while(st%q==0){
					t++;
					st/=q;
					if(r[q]<t) r[q]=t;
				}
			}
		}
	}
	if(!Flag){
		for(int i=0;i<m;i++){
			int st=pp[i]-1;
			while(st>1){
				int q=flag[st];
				int t=0;
				while(st%q==0){
					t++;
					st/=q;
				}
				if(s[q]<t){
					num[q]=1;
					s[q]=t;
				}
				else if(s[q]==t) num[q]++;
			}
		}
		for(int i=0;i<m;i++){
			int Vst=0;
			int st=pp[i]-1;
			while(st>1){
				int q=flag[st];
				int t=0;
				while(st%q==0){
					t++;
					st/=q;
				}
				if(t==s[q]&&num[q]==1) Vst=1;
			}
			if(!Vst){
				Flag=1;
				break;
			}
		}
	}
	int ans=1;
	for(int i=2;i<=p[1];i++) ans=(long long)ans*power(i,r[i],mod)%mod;
	ans+=Flag;
	ans%=mod;
	printf("%d\n",ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

// This code uses the bossle/cp library
// Available at https://github.com/bossle/cp

// #pragma STDC FENV_ACCESS OFF
// #pragma STDC FP_CONTRACT ON
// #pragma STDC CX_LIMITED_RANGE ON
// #pragma GCC optimize "O3"

namespace cp_base {

auto init = (
  ios::sync_with_stdio(false),
  cin.tie(nullptr)
);

}  // namespace cp_base

#define LOG(x)

typedef long long int lli;

const lli MOD = 1e9+7;

int main() {
  vector<int> primeFactor(2e6+1, -1);
  for (int i=2; i<primeFactor.size(); ++i) {
    if (primeFactor[i] == -1) {
      for (int j=i; j<primeFactor.size(); j+=i)
        primeFactor[j] = i;
    }
  }
  int n;
  cin >> n;
  vector<int> inp(n);
  for (int& i : inp)
    cin >> i;
  sort(inp.begin(), inp.end(), greater<int>());
  vector<int> pPow(2e6+1, 0), contributors(2e6+1, 0), choice(inp.size());
  for (int id=0; id<inp.size(); ++id) {
    int i = inp[id];
    if (pPow[i] == 0) {
      choice[id] = i;
      pPow[i] = 1;
      contributors[i] = 1;
    } else {
      choice[id] = i-1;
      int x = i-1;
      while (x > 1) {
        int f = primeFactor[x];
        int pow;
        for (pow=0; x%f==0; ++pow)
          x /= f;
        if (pPow[f] < pow) {
          pPow[f] = pow;
          contributors[f] = 1;
        } else if (pPow[f] == pow) {
          contributors[f]++;
        }
      }
    }
  }
  bool plus1 = false;
  for (int x : choice) {
    bool contributes = false;
    while (x > 1) {
      int f = primeFactor[x];
      int pow;
      for (pow=0; x%f==0; ++pow)
        x /= f;
      if (pPow[f] == pow && contributors[f] == 1)
        contributes = true;
    }
    if (!contributes)
      plus1 = true;
  }
  lli ans=1;
  for (int x=0; x<pPow.size(); ++x) {
    for (int i=0; i<pPow[x]; ++i)
      ans = (ans*x)%MOD;
  }
  if (plus1)
    ans = (ans+1)%MOD;
  cout << ans << endl;
}

//In the Name of God
//Ya Ali

#include <bits/stdc++.h>

#define err(A) cout << #A << " = " << (A) << endl

using namespace std;

const long long M = 1e9 + 7;

const int maxn = 2002002;

int fp[maxn];

int n;

int p[maxn];

int a[maxn];

int hav[maxn];
int hac[maxn];

long long ans = 1;

bool rizadd(int x)
{
  bool good = false;
  while (x != 1)
    {
      int cnt = 0;
      int px = fp[x];
      while (x % px == 0)
	{
	  cnt ++;
	  x /= px;
	}
      if (hav[px] < cnt)
	{
	  for (; hav[px] < cnt; hav[px] ++)
	  {
	    ans = ans * px % M;
	    good = true;
	  }
	  hac[px] = 1;
	}
      else if (hav[px] == cnt)
	{
	  hac[px] ++;
	}
    }

  return good;
}

bool add(int i, int x)
{
  if (!hav[x])
    {
      ans = ans * x % M;
      hav[x] = 1;
      a[i] = x;
      hac[x] = 1;
      return true;
    }
  else
    {
      a[i] = x - 1;
      return rizadd(x - 1);
    }
}

bool check(int x)
{
  while (x != 1)
    {
      int cnt = 0;
      int px = fp[x];
      while (x % px == 0)
	{
	  cnt ++;
	  x /= px;
	}
      if (cnt == hav[px] and hac[px] <= 1)
	return false;
    }
  return true;
}

int32_t main()
{
  ios::sync_with_stdio(0); cin.tie(0);

  for (int i = 2; i < maxn; i ++)
    if (!fp[i])
      for (int j = i; j < maxn; j += i)
	fp[j] = i;

  cin >> n;

  for (int i = 0; i < n; i ++)
    cin >> p[i];

  int rem = 0;

  sort(p, p + n);
  reverse(p, p + n);

  for (int i = 0; i < n; i ++)
    if (!add(i, p[i]))
      rem = 1;

  for (int i = 0; i < n; i ++)
    if (check(a[i]))
      rem = 1;

  cout << (ans + rem) % M << endl;

  return 0;
}

#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int cys=1000000007;
int n,tot;
ll a[200005],p[2000005],cnt[2000005],prm[10005];
bool fl[10005];
vector<pii> v[200005];

ll qpow(ll x,ll p){
	ll ret=1;
	for(;p;p>>=1,x=x*x%cys) if(p&1) ret=ret*x%cys;
	return ret;
}

void getprime(int N){
	fl[1]=1;
	for(int i=2;i<=N;i++){
		if(!fl[i]) prm[++tot]=i;
		for(int j=1;j<=tot&&i*prm[j]<=N;j++){
			fl[i*prm[j]]=1;
			if(i%prm[j]==0) break;
		}
	}
}

int main(){
	getprime(10000);
	n=readint();
	for(int i=1;i<=n;i++) a[i]=readint();
	sort(a+1,a+n+1); reverse(a+1,a+n+1);
	ll ans=1;
	for(int i=1;i<=n;i++){
		if(!p[a[i]]) v[i].push_back(mp(a[i],1)),p[a[i]]=1;
		else{
			int tmp=a[i]-1;
			for(int j=1;j<=tot&&prm[j]<=sqrt(tmp);j++){
				if(tmp%prm[j]==0){
					ll cnt=0;
					while(tmp%prm[j]==0) cnt++,tmp/=prm[j];
					chkmax(p[prm[j]],cnt);
					v[i].push_back(mp(prm[j],cnt));
				}
			}
			if(tmp>1){
				chkmax(p[tmp],1ll);
				v[i].push_back(mp(tmp,1));
			}
		}
	}
	for(int i=1;i<=n;i++) for(auto r:v[i]) if(r.se==p[r.fi]) cnt[r.fi]++;
	bool ff=0;
	for(int i=1;i<=n;i++){
		bool can=1;
		for(auto r:v[i]) if(r.se==p[r.fi]&&cnt[r.fi]==1) can=0;
		if(can){
			ff=1;
			break;
		}
	}
	for(int i=1;i<=2000000;i++) ans=ans*qpow(i,p[i])%cys;
	printf("%lld\n",(ans+ff)%cys);
	return 0;
}

#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int p[200010];
bool yes[2000010];
int d[2000010],pr[200010],P,pd[2000010];
int pw[200010],cnt[200010];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=2;i<=2000000;++i){
		if(!yes[i])pr[++P]=i,d[i]=P,pd[i]=1;
		for(int j=1;j<=P&&i*pr[j]<=2000000;++j){
			yes[i*pr[j]]=1;
			d[i*pr[j]]=j;
			if(i%pr[j]==0){pd[i*pr[j]]=pd[i]+1;break;}
			pd[i*pr[j]]=1;
		}
	}
	for(int i=1;i<=n;++i)p[i]=std::lower_bound(pr+1,pr+P+1,gi())-pr;
	std::sort(p+1,p+n+1);
	for(int i=n;i;--i){
		int x=pr[p[i]];
		if(!pw[p[i]])pw[p[i]]=cnt[p[i]]=1,p[i]=0;
		else{
			--x;
			while(x>1){
				int y=d[x],py=pd[x];
				if(pw[y]<py)pw[y]=py,cnt[y]=1;
				else if(pw[y]==py)++cnt[y];
				while(x%pr[y]==0)x/=pr[y];
			}
		}
	}
	int qwq=0;
	for(int i=1;i<=n;++i){
		int x=pr[p[i]]-1,now=1;
		while(x>1){
			int y=d[x],py=pd[x];
			if(pw[y]==py&&cnt[y]==1)now=0;
			while(x%pr[y]==0)x/=pr[y];
		}
		if(x==1)qwq|=now;
	}
	int ans=1;
	for(int i=1;i<=P;++i)ans=1ll*ans*pow(pr[i],pw[i])%mod;
	printf("%d\n",(ans+qwq)%mod);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define debug_arr(a) { cout << #a << " ";rep(i, 0, sz(a)) cout << a[i] << " \n"[i == n - 1]; }
#define debug(a) cerr << #a << ": " << (a) << '\n';
#define debug_two(a, b) cerr << #a << ": " << (a) << ", " << #b << ": " << (b) << '\n';

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int INF = 1000000000 + 7;
const ll LL_INF  = 1ll * INF * INF;
const int MAX_N = 2000000 + 7;

template <typename T>
inline void addmod(T& a, const ll& b, const int& MOD = INF) {
	a = (a + b) % MOD; if (a < 0) a += MOD;
}

class Prime {
public:
  static const int MAX_N = ::MAX_N;
  int primes[MAX_N];
  int last[MAX_N];
  int prime_count = 0;

  Prime() {
    init();
  }

  void sieve() {
    for(int i = 2; i < MAX_N; ++i) {
      if (last[i] == 0) {
        last[i] = i;
        primes[prime_count++] = i;
      }

      for(int j = 0; j < prime_count && primes[j] <= last[i] && primes[j] * i < MAX_N; ++j) {
        last[i * primes[j]] = primes[j];
      }
    }
  }

  void init() {
    prime_count = 0;
    sieve();
  }

  int operator[](const int& pos) const {
    return primes[pos];
  }

  int size() const {
    return prime_count;
  }

  bool is_prime(int x) const {
    return last[x] == x;
  }

  static long long numberInFactorial(long long prime, long long n) {
    long long res = n / prime;
    long long x = prime;
    const auto limit = n / prime;

    do {
      x *= prime;
      res += n / x;
    } while (x <= limit);

    return res;
  }
} primes;

int n;
int p[MAX_N];
int checked[MAX_N];
int chosen[MAX_N];

void solve() {
  cin >> n;
  rep(i, 0, n) {
    cin >> p[i];
  }
  sort(p, p + n, ::greater<>());

  bool extra = false;

  set<int> has;

  for (int i = 0; i < n; ++i) {
    if (!checked[p[i]]) {
      checked[p[i]] = 1;
    } else {
      int u = p[i] - 1;
      has.insert(u);
      if (u > 1 && !checked[u]) {
        checked[u] = 1;
      } else {
        extra = true;
      }
      while (u != 1) {
        int last = primes.last[u];
        int cnt = 0;
        while (primes.last[u] == last) {
          u /= last;
          ++cnt;
        }
        if (cnt >= checked[last]) {
          checked[last] = cnt;
          chosen[last] = p[i] - 1;
        }
      }
    }
  }
  long long ans = 1;

  for (int i = 2; i < MAX_N; ++i) {
    if (primes.is_prime(i)) {
      rep(j, 0, checked[i]) {
        ans = ans * i % INF;
      }
    }
  }

  if (!extra) {
    for (int i = 0; i < MAX_N; ++i) if (chosen[i] && has.count(chosen[i])) {
      has.erase(chosen[i]);
    }
    extra = !has.empty();
  }

  if (extra) ++ans;
  cout << ans << '\n';
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
  const bool multiple_test = false;
  int test = 1;
	if (multiple_test)
		cin >> test;

	for(int i = 0; i < test; ++i) {
		//printf("Case #%d: ", i + 1);
		solve();
	}
#ifdef _LOCAL_
	cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}

#include<bits/stdc++.h>
using namespace std;

using ll = long long;
const ll MOD = int(1e9) + 7;

const int MAXV = 2.2e6;
const int V = 2.1e6;
int fac[MAXV];

int N;

int cnt[MAXV];
int has[MAXV];
int best[MAXV];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	for (int i = 2; i <= V; i++) {
		if (fac[i]) continue;
		for (int j = i; j <= V; j += i) {
			fac[j] = i;
		}
	}

	cin >> N;
	for (int i = 0; i < N; i++) {
		int p; cin >> p;
		assert(p <= V);
		assert(fac[p] == p);
		cnt[p]++;
	}

	ll res = 1;
	bool extra = false;

	for (int p = V; p >= 2; p--) {
		if (fac[p] != p) continue;
		if (cnt[p] && !has[p]) {
			cnt[p]--;
			has[p] = 1;
			best[p] = 1;
		}

		if (has[p]) {
			for (int i = 0; i < best[p]; i++) {
				res = res * ll(p) % MOD;
			}
		}

		if (!cnt[p]) continue;
		assert(has[p]);

		if (cnt[p] >= 2) extra = true;
		int v = p-1;
		while(v > 1) {
			int q = fac[v];
			int e = 0;
			while(v % q == 0) v /= q, e++;
			if (e > best[q]) {
				best[q] = e;
				has[q] = 0;
			}
			if (e == best[q]) {
				has[q] ++;
			}
		}
	}

	if (!extra) {
		for (int p = V; p >= 2; p--) {
			if (fac[p] != p) continue;
			if (cnt[p]) {
				// we have guys that went downwards
				assert(has[p]);
				int v = p-1;
				bool good = true;
				while (v > 1) {
					int q = fac[v];
					int e = 0;
					while(v % q == 0) v /= q, e++;
					if (e == best[q] && has[q] == 1) {
						good = false;
						break;
					}
				}
				if (good) {
					extra = true;
					break;
				}
			}
		}
	}

	if (extra) {
		res++;
		res %= MOD;
	}
	cout << res << '\n';

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 3e6;
const int MOD = 1e9 + 7;
int n, res = 1, mx, ct[N], cs[N], imp[N], ff;
int not_prime[N];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i)
    {
        int a;
        scanf("%d", &a);
        mx = max(mx, a);
        ct[a] ++;
    }
    for (int i = mx; i >= 1; -- i) if (ct[i])
    {
        int gg = 0;
        for (int j = i + i; j <= mx; j += i)
            if (cs[j]) gg = 1;
        if (!gg) cs[i] = 1, ct[i] --;
        cs[i - 1] += ct[i];
    }
    for (int i = 2; i <= mx; ++ i)
        if (!not_prime[i])
        {
            for (int j = i + i; j <= mx; j += i)
                not_prime[j] = 1;
            int q = 0, c = 0;
            for (int j = i; j <= mx; j += i)
                if (cs[j])
                {
                    int k = j, p = 0;
                    while (k % i == 0) k /= i, p ++;
                    if (p > q) q = p, c = cs[j];
                    else if (p == q) c += cs[j];
                }
            for (int j = i; j <= mx; j += i)
                if (cs[j])
                {
                    int k = j, p = 0;
                    while (k % i == 0) k /= i, p ++;
                    if (p == q && c == 1) imp[j] = 1;
                }
            while (q --) res = 1ll * res * i % MOD;
        }
    for (int i = 1; i <= mx; ++ i)
        if (cs[i] && !imp[i]) ff = 1;
    res = (res + ff) % MOD;
    printf("%d\n", res);
}

#include<bits/stdc++.h>
using namespace std;

const int maxn = 2050000;
const int mod = 1000000007;

int n;
int a[maxn],b[maxn];

int prime[maxn],flag[maxn],minn[maxn],num;

int arr[maxn],cst[maxn];

void getprime(){
	int N = 2000000;
	for(int i=2;i<=N;i++){
		if(!flag[i]) prime[++num] = i,minn[i] = i;
		for(int j=1;j<=num&&i*prime[j] <= N;j++){
			minn[i*prime[j]] = prime[j];
			flag[i*prime[j]] = 1;
			if(i%prime[j] == 0) break;
		}
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	getprime();minn[1] = 1;
	for(int i=n;i>=1;i--){
		if(arr[a[i]]){
			a[i]--;b[i] = a[i];
			int cnt = 0,now = minn[a[i]];
			while(a[i] != 1){
				if(minn[a[i]] == now) cnt++,a[i]/=minn[a[i]];
				else{
					if(cnt == arr[now]) cst[now]++;
					if(cnt > arr[now]) arr[now] = cnt,cst[now] = 1;
					now = minn[a[i]];cnt = 0;
				}
			}
			if(cnt == arr[now]) cst[now]++;
			if(cnt > arr[now]) arr[now] = cnt,cst[now] = 1;
		}else b[i] = a[i],arr[a[i]]=1,cst[a[i]] = 1;
	}
	int ans = 1;
	for(int i=1;i<=2000000;i++){
		for(int j=1;j<=arr[i];j++) ans = 1ll*ans*i%mod;
	}
	int totflg = 0;cst[1] = 0;
	for(int i=1;i<=n;i++){
		int cnt = 0,now = minn[b[i]],flg=0;
		while(b[i] != 1){
			if(minn[b[i]] == now) cnt++,b[i]/=minn[b[i]];
			else{
				if(arr[now] == cnt&&cst[now]==1)flg = 1;
				now = minn[b[i]];cnt = 0;
			}
		}
		if(arr[now] == cnt&&cst[now]==1)flg = 1;
		if(!flg) totflg = 1;
	}
	ans += totflg; ans%=mod;
	printf("%d",ans);
	return 0;
}

//��CF1053D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 2e6+26;
const int MO = 1e9+7;
int n,a[N],b[N],c[N],d[N],e[N],r[N];
int main()
{
	int i,j,x,f;
	scanf("%d",&n);
	while(n--){
		scanf("%d",&x);
		a[x]++;
	}
	n=2e6;
	for(i=2;i<=n;i=i+1)
		for(j=i+i;j<=n;j=j+i)
			e[j]=1;
	for(i=n;i>1;i=i-1){
		if(!a[i])
			continue;
		a[i]--;
		x=0;
		for(j=i;j<=n;j=j+i)
			x|=b[j];
		if(x)
			b[i-1]++;
		else
			b[i]++;
		i++;
	}
	for(i=1;i<=n;i=i+1)
		for(j=i;j<=n;j=j+i)
			if(b[j])
				c[i]+=b[j],d[i]=j;
	f=1;
	for(i=2;i<=n;i=i+1){
		if(e[i])
			continue;
		x=1;
		while((LL)x*i<=n&&c[x*i]){
			x*=i;
		}
		f=(LL)f*x%MO;
		if(c[x]==1)
			r[d[x]]=1;
	}
	for(i=1;i<=n;i=i+1){
		if(b[i]&&!r[i]){
			f++;
			break;
		}
	}
	cout<<f%MO;
	return 0;
}

//>> OI Solution Info <<//
// Version: 2
// State: Progress
// Problem: Linear Congruential Generator
// ID: CF 1053D
// Timeline:
//   --- ~ --- Initialize
// Review:
//   ---
//>> End <<//
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 y_0
#define y1 y_1
#define yn y_n
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;
const int Mod=1000000007;

vector<int> prime;
bool nprime[2000005];
int index[2000005];

void preprocess(){
	memset(index,-1,sizeof index);
	nprime[0]=nprime[1]=true;
	for(int i=2;i<=2000000;i++){
		if(nprime[i])continue;
		for(int j=i+i;j<=2000000;j+=i)nprime[j]=true;
		index[i]=prime.size();
		prime.push_back(i);
	}
}

vector<pair<int,int> > factor(int x){
	vector<pair<int,int> > res;
	int curr=0;
	while((long long)prime[curr]*prime[curr]<=x){
		int cnt=0;
		while(x%prime[curr]==0)cnt++,x/=prime[curr];
		if(cnt!=0)res.push_back(make_pair(prime[curr],cnt));
		curr++;
	}
	if(x!=1)res.push_back(make_pair(x,1));
	return res;
}

int fpow(int a,int b){
	if(b==0)return 1;
	long long res=fpow(a,b/2);
	(res*=res)%=Mod;
	return b%2==0?res:res*a%Mod;
}

int n,p[200005];
bool f[200005],used[150000],alt[150000];
int cnt[150000],mxid[150000];

int main(){
	preprocess();
	memset(mxid,-1,sizeof mxid);
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",p+i);
	sort(p,p+n);reverse(p,p+n);
	for(int i=0;i<n;i++){
		if(!used[index[p[i]]]){
			int ii=index[p[i]];
			used[ii]=f[i]=true;
			if(cnt[ii]<1)cnt[ii]=1,mxid[ii]=i,alt[ii]=false;
			else if(cnt[ii]==1)alt[ii]=true;
		}else{
			vector<pair<int,int> > res=factor(p[i]-1);
			for(size_t j=0;j<res.size();j++){
				int ii=index[res[j].first],ex=res[j].second;
				used[ii]=true;
				if(cnt[ii]<ex)cnt[ii]=ex,mxid[ii]=i,alt[ii]=false;
				else if(cnt[ii]==ex)alt[ii]=true;
			}
		}
	}
	long long res=1;
	for(size_t i=0;i<prime.size();i++){
		(res*=fpow(prime[i],cnt[i]))%=Mod;
	}
	bool fl=false;
	for(int i=0;i<n&&!fl;i++){
		if(f[i]){
			int ii=index[p[i]];
			if(mxid[ii]!=i||alt[ii])fl=true;
		}else{
			bool curr=true;
			vector<pair<int,int> > res=factor(p[i]-1);
			for(size_t j=0;j<res.size()&&curr;j++){
				int ii=index[res[j].first];
				if(mxid[ii]==i&&!alt[ii])curr=false;
			}
			if(curr)fl=true;
		}
	}
	if(fl)(res+=1)%=Mod;
	printf("%lld\n",res);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define MAX 2000005
#define int ll
ll MOD =1e9+7;
int powmod(int base,int exponent)
{
	if(exponent<0) exponent+=MOD-1;
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int smpf[MAX],m[MAX],arr[MAX];
multiset<int> ans[MAX];
main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	for(int i=2;i<MAX;i++)
		smpf[i]=i;
	for(int i=2;i<MAX;i++)
	{
		for(int j=i;j<MAX;j+=i)
		{
			if(smpf[j]==j)
				smpf[j]=i;
		}
	}
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
		m[arr[i]]++;
	}
	bool flag=false;
	for(int i=MAX-1;i>1;i--)
	{
	    bool fl = true;
		if(m[i]&&ans[i].size())
			m[i]=max(m[i],2LL),fl = false;

		if(m[i]>0&&fl)
		{
			ans[i].insert(1);
			while(ans[i].size()>2)
				ans[i].erase(ans[i].begin());
		}
		if(m[i]>1)
		{
			int temp=i-1;
			while(temp!=1)
			{
				int x=smpf[temp];
				int cnt=0;
				while(temp%x==0)
				{
					temp/=x;
					cnt++;
				}
				ans[x].insert(cnt);
				while(ans[x].size()>2)
					ans[x].erase(ans[x].begin());
			}
		}
	}
	for(int i=2;i<MAX;i++)
	{
		if(m[i]==2)
		{
			bool now=true;
			int temp=i-1;
			while(temp!=1)
			{
				int x=smpf[temp];
				int cnt=0;
				while(temp%x==0)
				{
					temp/=x;
					cnt++;
				}
				if(!(ans[x].size()>1&&cnt<=*ans[x].begin()))
				{

					now=false;
				}
			}
			if(now)
			{
				// cout<<i<<endl;
				flag=true;
			}
		}
		if(m[i]>2)
			flag=true;
	}
	ll prt=1;
	for(int i=2;i<MAX;i++)
	{
		if(ans[i].size())
		{
			//cout<<i<<" "<<*ans[i].rbegin()<<endl;
			prt*=powmod(i,*ans[i].rbegin());
		}
		prt%=MOD;
	}
	prt+=flag;
	prt%=MOD;
	cout<<prt<<endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2000001, MOD = 1e9 + 7;
int lcm[MAXN] = {0}, cnt[MAXN] = {0}, add = 0, pre[MAXN] = {0};
bool add_as[MAXN] = {0};
void go(LL p, int idx) {
  if (not lcm[p]) return ++lcm[p], void();
  add_as[idx] = true;
  bool upd = false;
  LL n = p - 1;
  for (; n != 1; ) {
    LL d = pre[n], t = 0;
    while (n % d == 0) ++t, n /= d;
    if (lcm[d] < t) lcm[d] = t, cnt[d] = 1, upd = true;
    else if (lcm[d] == t) ++cnt[d];
  }
  if (not upd) add = 1;
}
bool check(LL p, int idx) {
  LL n = p - 1;
  bool necessary = false;
  for (; n != 1; ) {
    LL d = pre[n], t = 0;
    while (n % d == 0) ++t, n /= d;
    if (lcm[d] == t and cnt[d] == 1) necessary = true;
  }
  if (not necessary) add = 1;
}
LL powmod(LL x, LL k) {
  LL ans = 1;
  for (LL cur = x % MOD; k; k >>= 1, cur = cur * cur % MOD) {
    if (k&1) ans = cur * ans % MOD;
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  vector<LL> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  for (int p = 2; p < MAXN; ++p) for (int n = p; n < MAXN; n += p) if (not pre[n]) {
    pre[n] = p;
  }
  sort(p.rbegin(), p.rend());
  for (int i = 0; i < n; ++i) go(p[i], i);
  for (int i = 0; i < n; ++i) if (add_as[i]) check(p[i], i);
  LL ans = 1;
  for (int i = 1; i < MAXN; ++i) (ans *= powmod(i, lcm[i])) %= MOD;
  (ans += add) %= MOD;
  cout << ans << '\n';
}

#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const int MAXN = 2000005;
const ll MOD = 1000000007;
int P[200005];
int pfac[MAXN], has[MAXN], tot[MAXN];
vector<pair<int, int>> contrib[200005];
int main() {
	for (int i = 2; i < MAXN; ++i) pfac[i] = i;
	for (int i = 2; i < MAXN; ++i)
		if (pfac[i] == i) {
			for (int j = i + i; j < MAXN; j += i)
				pfac[j] = i;
		}
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", &P[i]);
	sort(P, P + n);
	ll ans = 1;
	for (int i = n - 1; i >= 0; --i) {
		if (has[P[i]]) {
			int x = P[i] - 1;
			while (x > 1) {
				int p = pfac[x];
				int cnt = 0;
				while (x % p == 0) {
					x /= p;
					++cnt;
				}
				if (has[p] < cnt) tot[p] = 0;
				contrib[i].push_back({p, cnt});
				while (has[p] < cnt) {
					++has[p];
					ans = ans * p % MOD;
				}
				if (has[p] == cnt) ++tot[p];
			}
		} else {
			tot[P[i]] = 1;
			contrib[i].push_back({P[i], 1});
			has[P[i]] = 1;
			ans = ans * P[i] % MOD;
		}
	}
	for (int i = n - 1; i >= 0; --i) {
		bool bad = false;
		for (auto x : contrib[i]) {
			if (x.second == has[x.first]) {
				if (tot[x.first] == 1) bad = true;
			}
		}
		if (!bad) {
			++ans;
			break;
		}
	}
	ans %= MOD;
	printf("%lld\n", ans);
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = (int)2e5 + 1, maxm = (int)2e6 + 1, mod = (int)1e9 + 7;
int tot, pr[maxm], d[maxm];
int n, m, a[maxn];
pair<int, int> mx[maxm];
int main() {
	d[1] = 1;
	for(int i = 2; i < maxm; ++i) {
		if(!d[i])
			pr[tot++] = d[i] = i;
		for(int j = 0, k; (k = i * pr[j]) < maxm; ++j) {
			d[k] = pr[j];
			if(d[i] == pr[j])
				break;
		}
	}
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%d", a + i);
	sort(a, a + n);
	for(int i = n - 1; i >= 0; --i)
		if(!mx[a[i]].first) {
			mx[a[i]] = make_pair(a[i], 1);
		} else {
			--a[i];
			for(int tmp = a[i]; tmp > 1; ) {
				int p = d[tmp], pp = 1;
				for( ; d[tmp] == p; tmp /= p, pp *= p);
				if(mx[p].first < pp) {
					mx[p] = make_pair(pp, 1);
				} else if(mx[p].first == pp) {
					++mx[p].second;
				}
			}
		}
	bool adt = 0;
	for(int i = 0; !adt && i < n; ++i) {
		bool chk = 0;
		for(int tmp = a[i]; !chk && tmp > 1; ) {
			int p = d[tmp], pp = 1;
			for( ; d[tmp] == p; tmp /= p, pp *= p);
			chk |= mx[p].first == pp && mx[p].second == 1;
		}
		adt |= !chk;
	}
	int ans = 1;
	for(int i = 0; i < tot; ++i)
		if(mx[pr[i]].first)
			ans = (LL)ans * mx[pr[i]].first % mod;
	if(adt)
		(++ans) >= mod && (ans -= mod);
	printf("%d\n", ans);
	return 0;
}

#include<cstdio>
const int MAX=2000010,mod=1000000007;
int n,m,mp[MAX],c[MAX],d[MAX],ds[MAX];
bool ty[MAX];
void upd(int i,int x){x>d[i]?d[i]=x,ds[i]=1:x==d[i]?ds[i]++:0;}
int main(){
scanf("%d",&n);
for(int p;n--;)scanf("%d",&p),c[p>m?m=p:p]++;
for(int i=2;i<=m;i++)if(!mp[i])
for(int j=i;j<=m;j+=i)if(!mp[j])mp[j]=i;
int s=1,t=0;
for(int i=m;i;i--)for(int j=c[i];j--;){
if(d[i]){
for(int x=i-1;x>1;){
int p=mp[x],c=0;
for(;x%p==0;x/=p)c++;
for(int e=d[p];e<c;e++)s=1ll*s*p%mod;
upd(p,c);
}
ty[i]=1;
}
else upd(i,1),s=1ll*s*i%mod;
}
for(int i=m;i;i--)if(ty[i]){
bool fl=1;
for(int x=i-1;x>1;){
int p=mp[x],c=0;
for(;x%p==0;x/=p)c++;
if(c==d[p]&&ds[p]==1)fl=0;
}
if(fl)t=1;
}
printf("%d\n",(s+t)%mod);
}

/***********Template Starts Here***********/
#include <bits/stdc++.h>

#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod)x-=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))

using namespace std;

typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < vlong, vlong > pll;
typedef vector<pll> vll;
typedef vector<vlong> vl;

const vlong inf = 2147383647;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;
using ll = long long;

template<typename S, typename T>
void xmin(S&a, T const&b){if(b<a) a=b;}
template<typename S, typename T>
void xmax(S&a, T const&b){if(b>a) a=b;}

#ifdef DEBUG
     clock_t tStart = clock();
     #define debug(args...) {dbg,args; cerr<<endl;}
     #define timeStamp debug ("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)
     #define bug printf("%d\n",__LINE__);

#else
    #define debug(args...)  // Just strip off all debug tokens
    #define timeStamp
#endif

struct debugger{
    template<typename T> debugger& operator , (const T& v){
        cerr<<v<<" ";
        return *this;
    }
}dbg;

//int knightDir[8][2] = { {-2,1},{-1,2},{1,2},{2,1},{2,-1},{-1,-2},{1,-2},{-2,-1} };
//int dir4[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}

vlong ext_gcd ( vlong A, vlong B, vlong *X, vlong *Y ){
    vlong x2, y2, x1, y1, x, y, r2, r1, q, r;
    x2 = 1; y2 = 0;
    x1 = 0; y1 = 1;
    for (r2 = A, r1 = B; r1 != 0; r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y ) {
        q = r2 / r1;
        r = r2 % r1;
        x = x2 - (q * x1);
        y = y2 - (q * y1);
    }
    *X = x2; *Y = y2;
    return r2;
}

inline vlong modInv ( vlong a, vlong m ) {
    vlong x, y;
    ext_gcd( a, m, &x, &y );
    x %= m;
    if ( x < 0 ) x += m; //modInv is never negative
    return x;
}

inline vlong power ( vlong a, vlong p ) {
    vlong res = 1, x = a;
    while ( p ) {
        if ( p & 1 ) res = ( res * x );
        x = ( x * x ); p >>= 1;
    }
    return res;
}

inline vlong bigmod ( vlong a, vlong p, vlong m ) {
    vlong res = 1 % m, x = a % m;
    while ( p ) {
        if ( p & 1 ) res = ( res * x ) % m;
        x = ( x * x ) % m; p >>= 1;
    }
    return res;
}

/***********Template Ends Here***********/

signed gen(int T){
    mt19937 rng(43151);
    auto get_rand = [&](int64_t l, int64_t r){
        return uniform_int_distribution<int64_t>(l, r)(rng);
    };
    auto get_double = [&](double l, double r){
        return uniform_real_distribution<double>(l, r)(rng);
    };
    ofstream o("gen.txt");
    o << T << "\n";
    for(int cas=0;cas<T;++cas){
        /// GEN HERE

        o << "\n";
    }
    o << endl;
    o.close();
    return 0;
}

const int N = 2000000;

vector<int> sieve(N + 1);

void init() {
    iota(sieve.begin(), sieve.end(), 0);
    for (int i = 2; i * i <= N; i++) {
        if (sieve[i] == i) {
            for (int j = i * i; j <= N; j += i) {
                xmin(sieve[j], i);
            }
        }
    }
}

vector<pair<int, int>> factorize(int n) {
    vector<pair<int, int>> res;
    while (n > 1) {
        int p = sieve[n];
        res.pb({p, 0});
        while (n % p == 0) {
            res.back().second++;
            n /= p;
        }
    }
    return move(res);
}

const int mod = 1000000007;

signed main()
{
    init();
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int TTT; cin >> TTT;
	if(TTT < 0) return gen(-TTT);
	while(TTT--){
    #else
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    #endif // LOCAL_RUN

    ///CODE
    int n;
    cin >> n;
    vector<int> P(n);
    for (int &p: P) {
        cin >> p;
    }
    sort(P.rbegin(), P.rend());
    unordered_map<int, int> exps, freqs;
    vector<vector<pair<int, int>>> facs(n);
    vector<bool> used(n);
    FOR(i, 0, n - 1) {
        facs[i] = factorize(P[i] - 1);
        if (exps[P[i]] == 0) {
            exps[P[i]] = 1;
            freqs[P[i]] = 1;
            used[i] = true;
            continue;
        }
        for (auto it: facs[i]) {
            int p = it.first, q = it.second;
            if (q > exps[p]) {
                exps[p] = q;
                freqs[p] = 1;
            } else if (q == exps[p]) {
                freqs[p]++;
            }
        }
    }
    vlong res = 1;
    for (auto it: exps) {
        int p = it.first, q = it.second;
        FOR(i, 1, q) {
            res = MOD(res, p);
        }
    }
    bool flag = false;
    FOR(i, 0, n - 1) {
        bool valid = true;
        if (used[i]) {
            if (exps[P[i]] == 1 and freqs[P[i]] == 1) {
                valid = false;
            }
        } else {
            for (auto it: facs[i]) {
                int p = it.first, q = it.second;
                if (q == exps[p] and freqs[p] == 1) {
                    valid = false;
                }
            }
        }
        if (valid) {
            flag = true;
        }
    }
    if (flag) {
        res++;
        NORM(res);
    }
    cout << res << endl;

    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
    return 0;
}

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=2e6+10;
const int mod=1e9+7;
int n,a[N],cnt[N],m[N],ans=1,P[N],val[N];
bool used[N];
void Lin_Sie(){
	used[1]=1;
	for(int i=2;i<N;i++){
		if(!used[i])P[++P[0]]=i,val[i]=i;
		for(int j=1;j<=P[0]&&1ll*i*P[j]<N;j++){
			used[i*P[j]]=1;
			val[i*P[j]]=P[j];
			if(i%P[j]==0)break;
		}
	}
}
int main()
{
	n=read();

	Lin_Sie();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
 	for(int i=n;i>=1;i--){
 		if(!cnt[a[i]])cnt[a[i]]++,m[a[i]]=1,ans=(1ll*ans*a[i])%mod;
 		else{
 	    int v=--a[i];
 	    while(v!=1){
    		int u=val[v],ls=0;
    		while(v%u==0)v/=u,ls++;
    		if(cnt[u]<ls){
    			for(int j=cnt[u]+1;j<=ls;j++)ans=(1ll*ans*u)%mod;
    			cnt[u]=ls;m[u]=1;
				}
				else if(cnt[u]==ls)m[u]++;
 			}
 		}
 	}
	for(int i=1;i<=n;i++){
		int v=a[i],flag=0;
		while(v!=1){
			int u=val[v],ls=0;
			while(v%u==0)v/=u,ls++;
			if(cnt[u]==ls&&m[u]==1)flag=1;
		}
		if(!flag){ans++;break;}
	}
	printf("%d\n",ans);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
int p[200009];
int P[2000009];
int f[2000009];
int F[2000009];
vector<int> V[2000009];
long long sc = 0;
void fa(int x){
    //cout<<x<<endl;
    int s = 1;
    int y = x;
    while(x > 1){
            int z = P[x];
            int k = 0;
            while(x % z == 0){
                x /= z;
                k++;
            }
         //   cout<<z<<" "<<k<<endl;
            if(F[z] < k) F[z] = k, s= 0;
            V[z].push_back(k);
        }
    if(s) sc = 1;
}
void Fa(int x){
    int s = 1;
    int y = x;
    while(x > 1){
            int z = P[x];
            int k = 0;
            while(x % z == 0){
                x /= z;
                k++;
            }
            if(V[z].size() == 1 || (V[z].size() > 1 &&k > V[z][V[z].size()-2])) s = 0;
        }
    if(s) sc = 1;//cout<<y<<endl;
}
main(){
    int n;
    cin >> n;
    for(int i = 2; i <= 2e6; i++){
        if(P[i] == 0){
            for(int j = i; j <= 2e6; j+=i)
                P[j] = i;
        }
    }
    for(int i = 0; i < n; i++){
        cin >>p[i];
        f[p[i]]++;
    }

    long long ans = 1;
    vector<int> t;

    for(int i = 2e6; i >= 1; i--){
        if(f[i] == 0) continue;
        if(f[i] >= 3) sc = 1;
        if(f[i] >= 2){
            t.push_back(i);
            t.push_back(i-1);
            fa(i);
            fa(i-1);
            continue;
        }
        if(F[i]) fa(i-1),t.push_back(i-1);
        else fa(i),t.push_back(i);
    }

    for(int i = 0; i <= 2e6; i++)
        sort(V[i].begin(),V[i].end());
    for(int i = 0; i < t.size(); i++){
        Fa(t[i]);
    }
  //  cout<<sc<<endl;
    for(int i = 0; i <= 2e6; i++){
        for(int j = 0; j < F[i]; j++)
            ans = ans * (long long)i % mod;
    }
    if(sc) ans = (ans + 1) % mod;
    cout << ans << endl;

}

#include <bits/stdc++.h>

using namespace std;

const int N = 200010;
const int M = 2000010;
const int MOD = 1000000007;

inline int add(int u, int v) {
    u += v;
    if (u >= MOD) {
        u -= MOD;
    }
    return u;
}

inline int sub(int u, int v) {
    u -= v;
    if (u < 0) {
        u += MOD;
    }
    return u;
}

inline int mul(int u, int v) {
    return (long long)u * v % MOD;
}

inline int power(int u, int v) {
    int res = 1;
    while (v) {
        if (v & 1) {
            res = mul(res, u);
        }
        u = mul(u, u);
        v >>= 1;
    }
    return res;
}

inline int inv(int u) {
    return power(u, MOD - 2);
}

int n;
int p[M];
int a[N];
int maxPower[M], cntMaxPower[M];

vector<pair<int, int> > getPrimeDivs(int u) {
	vector<pair<int, int> > res;
	while (u > 1) {
		int v = p[u];
		res.push_back(make_pair(v, 0));
		while (u % v == 0) {
			u /= v;
			res.back().second++;
		}
	}
	return res;
}

bool canAdd(int u) {
	vector<pair<int, int> > primeDivs = getPrimeDivs(u);
	for (auto v : primeDivs) {
		if (v.second > maxPower[v.first]) {
			return true;
		}
	}
	return false;
}

void add(int u) {
	vector<pair<int, int> > primeDivs = getPrimeDivs(u);
	for (auto v : primeDivs) {
		if (v.second == maxPower[v.first]) {
			cntMaxPower[v.first]++;
		} else if (v.second > maxPower[v.first]) {
			maxPower[v.first] = v.second;
			cntMaxPower[v.first] = 1;
		}
	}
}

int used[N];

bool canRemove(int u) {
	vector<pair<int, int> > primeDivs = getPrimeDivs(u);
	for (auto v : primeDivs) {
		if (v.second == maxPower[v.first] && cntMaxPower[v.first] == 1) {
			return false;
		}
	}
	return true;
}

void remove(int u) {
	vector<pair<int, int> > primeDivs = getPrimeDivs(u);
	for (auto v : primeDivs) {
		if (v.second == maxPower[v.first]) {
			cntMaxPower[v.first]--;
		}
	}
}

int main() {
	for (int i = 2; i < M; i++) {
		if (!p[i]) {
			for (int j = i; j < M; j += i) {
				if (!p[j]) {
					p[j] = i;
				}
			}
		}
	}

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}
	sort(a + 1, a + n + 1);
	int tail = 0;
	for (int i = n; i > 0; i--) {
		if (canAdd(a[i])) {
			add(a[i]);
			used[i] = 1;
		} else if (canAdd(a[i] - 1)) {
			used[i] = 2;
			add(a[i] - 1);
		} else {
			tail = 1;
		}
	}
	for (int i = n; i > 0; i--) {
		if (used[i] == 0) {
			continue;
		}
		int u = used[i] == 1 ? a[i] : a[i] - 1;
		if (canRemove(u)) {
			remove(u);
			tail = 1;
		}
	}
	int res = 1;
	for (int i = 1; i < M; i++) {
		if (p[i] == i) {
			res = mul(res, power(i, maxPower[i]));
		}
	}
	res = add(res, tail);
	cout << res << endl;
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

const ll mod=1e9+7;
ll n,a[200010],prime[2000010],cnt[2000010],pre,ans=1,used[2000010];
bool unpri[2000010],tag[2000010];

inline bool cmp1(int x,int y){return x>y;}

inline void Eular(int N){
	for(int i=2;i<=N;i++){
		if(!unpri[i]) prime[++prime[0]]=i;
		for(int j=1;j<=prime[0]&&i*prime[j]<=N;j++){
			unpri[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}return;
}

inline bool work(ll x){
	int tmp,fail=1;
	for(int i=1;i<=prime[0];i++){
		if(prime[i]*prime[i]>x) break;tmp=0;
		while(x%prime[i]==0) tmp++,x/=prime[i];
		if(tmp>cnt[prime[i]]) fail=0,cnt[prime[i]]=tmp,used[prime[i]]=1;
		else if(tmp==cnt[prime[i]])used[prime[i]]++;
	}
	if(!cnt[x]) fail=0,cnt[x]=1,used[x]=1;
	else if(cnt[x]==1) used[x]++;
	return fail;
}

inline bool check(ll x){
	int tmp,fail=1;
	for(int i=1;i<=prime[0];i++){
		if(prime[i]*prime[i]>x) break;tmp=0;
		while(x%prime[i]==0) tmp++,x/=prime[i];
		if(tmp==cnt[prime[i]]&&used[prime[i]]==1) fail=0;
	}if(cnt[x]==1&&used[x]==1) fail=0;return fail;
}

inline ll qpow(ll x,ll k){
	ll res=1;
	while(k){
		if(k&1) res=res*x%mod;
		x=x*x%mod;k>>=1;
	}return res;
}

int main(){
	n=read();Eular(2000000);cnt[1]=1;
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1,cmp1);
	for(int i=1;i<=n;i++){
		if(!cnt[a[i]]) cnt[a[i]]++;
		else {tag[i]=1;if(work(a[i]-1)) pre=1;}
	}

	for(int i=1;i<=n;i++) if(tag[i]) if(check(a[i]-1)) pre=1;

	for(int i=2;i<=2000000;i++) ans=ans*qpow(i,cnt[i])%mod;
	cout<<(ans+pre)%mod<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int mxN=2e5, mxA=2e6, M=1e9+7;
int n, p[mxN], spf[mxA+1];
vector<int> pfs;
array<int, 2> a[mxA+1];
bool c[mxN];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	for(int i=2; i<=mxA; ++i) {
		if(!spf[i]) {
			pfs.push_back(i);
			spf[i]=i;
		}
		for(int j=0; j<pfs.size()&&pfs[j]<=spf[i]&&i*pfs[j]<=mxA; ++j)
			spf[i*pfs[j]]=pfs[j];
	}
	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> p[i];
	sort(p, p+n, greater<int>());
	for(int i=0; i<n; ++i) {
		c[i]=a[p[i]][0];
		int b=c[i]?p[i]-1:p[i];
		while(spf[b]) {
			int c=spf[b], d=0;
			while(b%c==0) {
				b/=c;
				++d;
			}
			if(a[c][0]<d)
				a[c]={d};
			if(a[c][0]==d)
				++a[c][1];
		}
	}
	long long ans=1;
	for(int i=2; i<=mxA; ++i)
		for(int j=0; j<a[i][0]; ++j)
			ans=i*ans%M;
	for(int i=0; i<n; ++i) {
		if(!c[i])
			continue;
		int b=p[i]-1;
		bool ok=1;
		while(spf[b]&&ok) {
			int c=spf[b], d=0;
			while(b%c==0) {
				b/=c;
				++d;
			}
			ok=a[c]>array<int, 2>{d, 1};
		}
		if(ok) {
			++ans;
			break;
		}
	}
	cout << ans;
}

#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e6+10;
const int mod=1e9+7;
int prime[N],pp,pri[N],ans=1,p[N],n,cnt[N],mx[N];
bool iscomp[N];
void primetable()
{
	for(int i=2;i<N;i++)
	{
		if(!iscomp[i])prime[pp++]=i,pri[i]=i;
		for(int j=0;j<pp&&1ll*i*prime[j]<N;j++)
		{
			iscomp[i*prime[j]]=1;
			pri[i*prime[j]]=prime[j];
			if(i%prime[j]==0)break;
		}
	}
}
int main()
{
	primetable();
	scanf("%d\n",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
    sort(p+1,p+n+1);
    for(int i=n;i;i--)
    {
    	if(!cnt[p[i]])cnt[p[i]]++,mx[p[i]]=1,ans=(1ll*ans*p[i])%mod;
    	else
    	{
    		int v=--p[i];
    		while(v!=1)
    		{
    			int u=pri[v],ci=0;
    			while(v%u==0)v/=u,ci++;
    			if(cnt[u]<ci)
    			{
    				for(int j=cnt[u]+1;j<=ci;j++)ans=(1ll*ans*u)%mod;
    				cnt[u]=ci;mx[u]=1;
				}
				else mx[u]+=(cnt[u]==ci);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		int v=p[i],flag=0;
		while(v!=1)
		{
			int u=pri[v],ci=0;
			while(v%u==0)v/=u,ci++;
			if(cnt[u]==ci&&mx[u]==1)flag=1;
		}
		if(!flag)
		{
			ans++;break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

#include<cstdio>
const int MAX=2000010,mod=1000000007;
int n,m,mp[MAX],c[MAX],d[MAX],ds[MAX];
bool ty[MAX];
void upd(int i,int x){x>d[i]?d[i]=x,ds[i]=1:x==d[i]?ds[i]++:0;}
int main(){
	scanf("%d",&n);
	for(int p;n--;)scanf("%d",&p),c[p>m?m=p:p]++;
	for(int i=2;i<=m;i++)if(!mp[i])
		for(int j=i;j<=m;j+=i)if(!mp[j])mp[j]=i;
	int s=1,t=0;
	for(int i=m;i;i--)for(int j=c[i];j--;){
		if(d[i]){
			for(int x=i-1;x>1;){
				int p=mp[x],c=0;
				for(;x%p==0;x/=p)c++;
				for(int e=d[p];e<c;e++)s=1ll*s*p%mod;
				upd(p,c);
			}
			ty[i]=1;
		}
		else upd(i,1),s=1ll*s*i%mod;
	}
	for(int i=m;i;i--)if(ty[i]){
		bool fl=1;
		for(int x=i-1;x>1;){
			int p=mp[x],c=0;
			for(;x%p==0;x/=p)c++;
			if(c==d[p]&&ds[p]==1)fl=0;
		}
		if(fl)t=1;
	}
	printf("%d\n",(s+t)%mod);
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxp=2e6+20;
const int maxn=maxp;
const int mod=1e9+7;

int n,p[maxn],mark[maxn],prime[maxn],tot,d[maxn];

inline void prepare()
{
	REP(i,2,2e6)
	{
		if(!mark[i])prime[++tot]=i,mark[i]=tot,d[i]=i;
		for(int j=1;i*prime[j]<=2e6;j++)
		{
			int k=i*prime[j]; mark[k]=1; d[k]=prime[j];
			if(!(i%prime[j]))break;
		}
	}
}

inline void init()
{
	n=read();
	REP(i,1,n)p[i]=read();
	sort(p+1,p+n+1);
}

int cnt[maxp],ok[maxp];
int tag[maxp];

inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

inline void doing()
{
	DREP(i,n,1)
	{
		int x=p[i];
		if(!cnt[x])
		{
			cnt[x]=1;tag[x]=1;ok[i]=0;
		}else
		{
			ok[i]=1;
			int u=x-1;
			while(u>1)
			{
				int t=d[u],sum=0;
				while(!(u%t))u/=t,sum++;
				if(cnt[t]<sum)cnt[t]=sum,tag[t]=1;
				else if(cnt[t]==sum)tag[t]++;
			}
		}
	}

	int ad=0;

	DREP(i,n,1)
	{
		int u=p[i]-ok[i],flg=1;
		while(u>1)
		{
			int t=d[u],sum=0;
			while(!(u%t))u/=t,sum++;
			if(tag[t]==1 && cnt[t]==sum)flg=0;
		}
		ad|=flg;
	}
	int ans=1;
	REP(i,1,2e6)if(cnt[i])ans=(ll)ans*power(i,cnt[i])%mod;
	printf("%d\n",(ans+ad)%mod);
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("linear.in","r",stdin);
	freopen("linear.out","w",stdout);
#endif
	prepare();
	init();
	doing();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int const N = 200000, M = 2000000, md = 1e9 + 7;
int dv[M + 1], x[N];
pair<int, int> fr[M + 1];

void up(int i, int z){
	if (z > fr[i].first)fr[i] = make_pair(z, 1);
	else if (z == fr[i].first)++fr[i].second;
}

void ad(int x){
	int lst = 0, z = 0;
	while (x > 1){
		int d = dv[x];
		if (d != lst){
			up(lst, z);
			lst = d, z = 1;
		}else ++z;
		x /= d;
	}
	up(lst, z);
}

bool useless(int x){
	int lst = 0, z = 0;
	while (x > 1){
		int d = dv[x];
		if (d != lst){
			if (z == fr[lst].first && fr[lst].second == 1)return false;
			lst = d, z = 1;
		}else ++z;
		x /= d;
	}
	if (z == fr[lst].first && fr[lst].second == 1)return false;
	return true;
}

int main(){
	f(i, 2, M + 1)if (!dv[i]){
		dv[i] = i;
		for (int j = i + i; j <= M; j += i)if (!dv[j])dv[j] = i;
	}
	int n;
	scanf("%d", &n);
	f(i, 0, n)scanf("%d", x + i);
	sort(x, x + n);
	reverse(x, x + n);
	f(i, 0, n)if (!fr[x[i]].first)up(x[i], 1);
	else ad(x[i] = x[i] - 1);
	bool p1 = false;
	fr[0].second = 2;
	f(i, 0, n)if (useless(x[i])) { p1 = true; break; }
	int an = 1;
	f(i, 2, M + 1)while (fr[i].first--)an = (ll)an * i % md;
	if (p1 && ++an == md)an = 0;
	printf("%d\n", an);
}

#include<bits/stdc++.h>
#define maxn 2000005

using namespace std;
typedef long long ll;
const ll M=1000000007;
int p[maxn],a[maxn],n,prime[maxn],ans,d,t,c[maxn],cc[maxn];
bool f[maxn],ff[maxn],g;
vector <int> h[maxn];

void prime_sieve(){
    p[1]=1; t=0;
    for (int i=2;i<maxn;i++){
        if (!p[i]) prime[++t]=i;
        for (int j=1;j<=t;j++){
            if (1ll*prime[j]*i>=maxn) break;
            p[prime[j]*i]=1;
            if (i%prime[j]==0) break;
        }
    }
}
bool check(ll x){
    if (x>=maxn) return false;
    for (int i=1;x*i<maxn;i++) if (f[x*i]) return true;
    return false;
}
int cnt(int x){
    int res=0; for (int i=1;i*x<maxn;i++) res+=c[i*x]; return res;
}

int main(){
    prime_sieve();
    for (int i=1;i<=t;i++)
        for (int j=1;j*prime[i]<maxn;j++)
            h[j*prime[i]].push_back(prime[i]);
    cin >> n;
    for (int i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n); ans=1;
    for (int i=n-1;i>=0;i--){
        if (!f[a[i]]) f[a[i]]=true,c[a[i]]++;
        else {
            int tt=a[i]-1; f[tt]=true,c[tt]++;
            for (int j=0;j<h[tt].size();j++) f[h[tt][j]]=true;
        }
    }
    for (int i=2;i<maxn;i++) if (c[t]>1) g=true;
    if (c[1]) g=true;
    for (int i=1;i<=t;i++){
        int r=prime[i],x=1;
        while (check(1ll*x*prime[i])) x=x*prime[i];
        ans=1ll*x*ans%M;
        if (x==1) continue;
        a[prime[i]]=x; cc[prime[i]]=cnt(x);
        //if (x>1)cout<<prime[i]<<' '<<cc[prime[i]]<<endl;
    }
    //for (int i=2;i<=5;i++)cout<<c[i]<<' ';cout<<endl;
    //cout<<g<<endl;
    if (!g){
        for (int i=2;i<maxn;i++) if (c[i]){
            //cout<<i<<endl;
            bool flag=true;
            for (int j=0;j<h[i].size();j++){
                int P=h[i][j];
                //cout<<'!'<<P<<endl;
                if (i%a[P]==0&&cc[P]==1) flag=false;
            }
            if (flag){
                g=true;
                break;
            }
        }
    }
    cout << (ans+g)%M << endl;
}

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define pr pair<int,int>
	#define FR first
	#define SE second
	#define MP make_pair
	#define PB push_back
	#define vc vector
	void chmax(int &x,const ll y) {x=(x>y?x:y);}
	void chmin(int &x,const ll y) {x=(x<y?x:y);}
	ll qread()
	{
		ll 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(ll num)
	{
		if(num<0) putchar('-'),num=-num;
		if(num>=10) write(num/10);
		putchar('0'+num%10);
	}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	void add(ll &a,ll b){a+=b;if(a>=MOD)a-=MOD;if(a<=-MOD)a+=MOD;}
	ll qpower(ll x,int e)
	{
		ll ans=1;
		while(e)
		{
			if(e&1) ans=ans*x%MOD;
			x=x*x%MOD;e>>=1;
		}
		return ans;
	}
	ll invm(ll 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 (ll)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];
	pr cnt[MAX_N];
	void insert(int id,int num)
	{
		if(num>=cnt[id].FR) cnt[id].SE=cnt[id].FR,cnt[id].FR=num;
		else if(num>cnt[id].SE) cnt[id].SE=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].FR!=cnt[id].SE and cnt[id].FR==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]] ].FR) {cnt[ mip[p[i]] ].FR=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;}
		ll ans=1;
		for(int i=1;i<=pp;i++) {while(cnt[i].FR--) ans=ans*prm[i]%MOD;}
		write((ans+bk)%MOD);
	}
};
int main()
{
	// freopen("jump.in","r",stdin);
	// freopen("jump.out","w",stdout);
	srand(time(0));
	mine::main();
}

//Codeforces Round #512 D. Linear Congruential Generator
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=210005,M=2000005,p=1000000007;
int read(){
    int f=1,g=0;char ch=getchar();
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
    for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
    return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,a[N],pr[M],f[M],b[M],cnt[M],ans,fl;
void add(int t,int k){
	if (b[t]<k){b[t]=k;cnt[t]=1;}
	else if (b[t]==k) cnt[t]++;
}
bool check(int t,int k){return (k<b[t])||(cnt[t]>1);}
void calc(int x){
	while (x>1){
		int t=0,k=f[x];
		while (f[x]==k){t++;x/=k;}
		add(k,t);
	}
}
bool res(int x){
	while (x>1){
		int t=0,k=f[x];
		while (f[x]==k){t++;x/=k;}
		if (!check(k,t)) return false;
	}
	return true;
}

int main(){
//	freopen("1.in","r",stdin);
	for (int i=2;i<M;i++){
		if (!f[i]){f[i]=pr[++pr[0]]=i;}
		for (int j=1;(j<=pr[0])&&(pr[j]<=f[i])&&(i*pr[j]<M);j++)
		f[i*pr[j]]=pr[j];
	}
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	for (int i=n;i;i--)
	if (b[a[i]]) {a[i]--;calc(a[i]);}else add(a[i],1);
	for (int i=1;i<=n;i++)
	if (res(a[i])) fl=1;
	ans=1;
	for (int i=2;i<M;i++)
	if (b[i]) ans=(ll)ans*qpow(i,b[i])%p;
	printf("%d\n",(ans+fl)%p);
	return 0;
}

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=2e6+10;
const int mod=1e9+7;
int n,a[N];
int cnt[N],mx[N];
int ans=1;
bool used[N];
int prime[N],val[N];
void Lin_Sie(){
	used[1]=1;
	for(int i=2;i<N;i++){
		if(!used[i])prime[++prime[0]]=i,val[i]=i;
		for(int j=1;j<=prime[0]&&1ll*i*prime[j]<N;j++){
			used[i*prime[j]]=1;
			val[i*prime[j]]=prime[j];
			if(i%prime[j]==0)break;
		}
	}
}
int main()
{
	n=read();Lin_Sie();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
 	for(int i=n;i>=1;i--){
 		if(!cnt[a[i]])cnt[a[i]]++,mx[a[i]]=1,ans=(1ll*ans*a[i])%mod;
 		else{
 	    int v=--a[i];
 	    while(v!=1){
    		int u=val[v],ls=0;
    		while(v%u==0)v/=u,ls++;
    		if(cnt[u]<ls){
    			for(int j=cnt[u]+1;j<=ls;j++)ans=(1ll*ans*u)%mod;
    			cnt[u]=ls;mx[u]=1;
				}
				else if(cnt[u]==ls)mx[u]++;
 			}
 		}
 	}
	for(int i=1;i<=n;i++){
		int v=a[i],flag=0;
		while(v!=1){
			int u=val[v],ls=0;
			while(v%u==0)v/=u,ls++;
			if(cnt[u]==ls&&mx[u]==1)flag=1;
		}
		if(!flag){ans++;break;}
	}
	printf("%d\n",ans);
	return 0;
}

#include <iostream>
#include <cstdio>

#include <functional>
#include <algorithm>
#include <utility>

#include <cassert>

using namespace std;

#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 2e5 + 1000;
const int MAXV = 2e6 + 100;
const int PIV = 16e5;
const int MOD = 1e9 + 7;

int prod(int a, int b) {
    return static_cast<int>((static_cast<ll>(a)*b)%MOD);
}
int pow(int b, int p) {
    assert(p >= 0);
    int ret = 1;
    for(;p > 0;p >>= 1) {
        if(p&1) ret = prod(ret, b);
        b = prod(b, b);
    }
    return ret;
}

int N;
int p[MAXN];

int ploc[MAXV];
int pr[PIV], prs;

pii pf[PIV];
int pfs;

void fact(int n, bool alpr = false) {
    if(alpr) {
        pfs = 1;
        pf[0] = mp(ploc[n], 1);
        return;
    }
    pfs = 0;
    for(int i = 0;i < prs and pr[i] * pr[i] <= n;i++) {
        if(n%pr[i] == 0) {
            pf[pfs].first = i;
            pf[pfs].second = 0;
            for(;n%pr[i] == 0;n /= pr[i]) pf[pfs].second++;
            pfs++;
        }
    }
    if(n > 1) {
        pf[pfs++] = mp(ploc[n], 1);
    }
}

int ans[PIV];
bool dup[PIV];

bool chk(int n, bool alpr = false) {
    fact(n, alpr);
    for(int i = 0;i < pfs;i++) if(pf[i].second > ans[pf[i].first]) return true;
    return false;
}
bool ins(int n) {
    //fact(n);

    bool used = false;
    for(int i = 0;i < pfs;i++) {
        if(pf[i].second > ans[pf[i].first]) dup[pf[i].first] = false, ans[pf[i].first] = pf[i].second, used = true;
        else if(pf[i].second == ans[pf[i].first]) dup[pf[i].first] = true;
    }
    return used;
}

int u[MAXN], us;

int main() {
    scanf("%d", &N);

    for(int i = 0;i < MAXV;i++) ploc[i] = -1;
    for(int i = 0;i < PIV;i++) ans[i] = dup[i] = 0;

    prs = 0;
    for(int i = 2;i < MAXV;i++) {
        bool pm = true;
        for(int j = 0;j < prs and pr[j] * pr[j] <= i;j++) if(i%pr[j] == 0) {
            pm = false;
            break;
        }
        if(pm) {
            pr[prs] = i, ploc[i] = prs;
            prs++;
        }
    }

    for(int i = 0;i < N;i++) scanf("%d", p + i);

    sort(p, p + N, greater<int>());

    bool a0 = false;

    us = 0;
    for(int i = 0, j;i < N;i = j) {
        for(j = i;j < N and p[j] == p[i];j++);

        int amo = j - i;

        if(amo) {
            if(chk(p[i], true)) {
                assert(ins(p[i]));
                u[us++] = p[i];
                amo--;
            }
        }
        if(amo and p[i] != 2) {
            if(chk(p[i] - 1, false)) {
                assert(ins(p[i] - 1));
                u[us++] = p[i] - 1;
                amo--;
            }
        }
        if(amo) a0 = true;
    }

    if(!a0) {
        for(int i = 0;i < us;i++) {
            fact(u[i]);

            bool crem = true;
            for(int k = 0;k < pfs;k++) if(ans[pf[k].first] == pf[k].second and !dup[pf[k].first]) {
                crem = false;
                break;
            }

            if(crem) {
                a0 = true;
                break;
            }
        }
    }

    int fin = 1;
    for(int i = 0;i < PIV;i++) {
        fin = prod(fin, pow(pr[i], ans[i]));
    }
    fin = (a0 + fin)%MOD;

    printf("%d\n", fin);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 2e6;
int main(int argc, char *argv[]) {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> primes;
	vector<int> lp(MAX + 1, 0);
	for(int i = 2; i <= MAX; i++) {
		if(not lp[i]) {
			lp[i] = i;
			primes.push_back(i);
		}
		for(auto p: primes) {
			if(p > lp[i] or i * p > MAX)
				break;
			lp[i * p] = p;
		}
	}
	vector<int> p(MAX + 1, 0);
	for(int i = 0; i < N; i++) {
		int t;
		cin >> t;
		p[t]++;
	}
	vector<int> q(MAX + 1, 0);
	vector<int> cnt(MAX + 1, 0);
	int TTT = 0;
	for(int i = MAX; i >= 1; i--) {
		if(p[i] >= 2) {
			if(q[i] < 1) {
				q[i] = 1;
				cnt[i] = 1;
			}
			else if(q[i] == 1)
				cnt[i]++;
			else
				TTT = 1;
			if(i == 2 || p[i] >= 3)
				TTT = 1;
			int t = i - 1;
			for(int lastp = lp[t], lpcnt = 0; t > 1; t /= lp[t]) {
				if(lastp == lp[t])
					lpcnt++;
				else {
					lastp = lp[t];
					lpcnt = 1;
				}
				if(q[lastp] < lpcnt) {
					q[lastp] = lpcnt;
					cnt[lastp] = 1;
				}
				else if(q[lastp] == lpcnt)
					cnt[lastp]++;
			}
		}
		else if(p[i] == 1) {
			if(q[i] == 0)
				q[i] = 1;
			else {
				if(i == 2)
					TTT = 1;
				int t = i - 1;
				for(int lastp = lp[t], lpcnt = 0; t > 1; t /= lp[t]) {
					if(lastp == lp[t])
						lpcnt++;
					else {
						lastp = lp[t];
						lpcnt = 1;
					}
					if(q[lastp] < lpcnt) {
						q[lastp] = lpcnt;
						cnt[lastp] = 1;
					}
					else if(q[lastp] == lpcnt)
						cnt[lastp]++;
				}
			}
		}
	}
	for(int i = MAX; i >= 1; i--) {
		if(p[i] >= 2 or (p[i] >= 1 and (q[i] > 1 or cnt[i] > 1))) {
			int t = i - 1;
			int ttt = 1;
			for(int lastp = lp[t], lpcnt = 0; t > 1; t /= lp[t]) {
				if(lastp == lp[t])
					lpcnt++;
				else {
					lastp = lp[t];
					lpcnt = 1;
				}
				if(q[lastp] == lpcnt and cnt[lastp] == 1)
					ttt = 0;
			}
			TTT |= ttt;
		}
	}
	int ans = 1;
	for(int i = 1; i <= MAX; i++)
		while(q[i]--)
			ans = ans * 1ll * i % MOD;
	cout << (ans + TTT) % MOD << endl;
	return 0;
}

#include<bits/stdc++.h>
#define MAX 2000010
#define P 1000000007LL
#define ll long long
using namespace std;
int cnt[MAX];
int mark[MAX];
int ans[MAX];
int d[MAX];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	for(int i = 2; i < MAX; i++){
		if(!d[i])
			for(int j = i; j < MAX; j += i){
				d[j] = i;
			}
	}
	int n;
	cin >> n;
	vector<int> v(n);

	int flag = 0;
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	vector<int> a;
	for(auto x : v){
		if(ans[x])
			x--;
		a.push_back(x);
		while(x > 1){
			int p = d[x];
			int q = 0;
			while(x % p == 0){
				x /= p;
				q++;
			}
			if(ans[p] < q){
				ans[p] = q;
				cnt[p] = 1;
			}
			else if(ans[p] == q)
				cnt[p]++;
		}

	}
	memset(mark, 0, sizeof(mark));
	for(auto x : a){
		int flag1 = 0;
		while(x > 1 && !flag1){
			int p = d[x];
			int q = 0;
			while(x % p == 0){
				x /= p;
				q++;
			}
			if(ans[p] == q && cnt[p] == 1)
				flag1 = 1;
		}

		flag |= !flag1;
	}

	long long res = 1LL;
	for(ll i = 2; i < MAX; i++){
		if(ans[i]){
			for(int j = 0; j < ans[i]; j++)
				res = (res * i) % P;
		}
	}
	res += flag;
	res %= P;
	cout << res << "\n";
	return 0;
}

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=2e6+10;
const int mod=1e9+7;
int n,a[N],cnt[N],m[N],ans=1,P[N],val[N];
bool used[N];
void Lin_Sie(){
	used[1]=1;
	for(int i=2;i<N;i++){
		if(!used[i])P[++P[0]]=i,val[i]=i;
		for(int j=1;j<=P[0]&&1ll*i*P[j]<N;j++){
			used[i*P[j]]=1;
			val[i*P[j]]=P[j];
			if(i%P[j]==0)break;
		}
	}
}
int main()
{
	n=read();

	Lin_Sie();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
 	for(int i=n;i>=1;i--){
 		if(!cnt[a[i]])cnt[a[i]]++,m[a[i]]=1,ans=(1ll*ans*a[i])%mod;
 		else{
 	    int v=--a[i];
 	    while(v!=1){
    		int u=val[v],ls=0;
    		while(v%u==0)v/=u,ls++;
    		if(cnt[u]<ls){
    			for(int j=cnt[u]+1;j<=ls;j++)ans=(1ll*ans*u)%mod;
    			cnt[u]=ls;m[u]=1;
				}
				else if(cnt[u]==ls)m[u]++;
 			}
 		}
 	}
	for(int i=1;i<=n;i++){
		int v=a[i],flag=0;
		while(v!=1){
			int u=val[v],ls=0;
			while(v%u==0)v/=u,ls++;
			if(cnt[u]==ls&&m[u]==1)flag=1;
		}
		if(!flag){ans++;break;}
	}
	printf("%d\n",ans);
	return 0;
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <set>
#include <cmath>

using namespace std;
typedef long long ll;
const int MAXN = 200100;
const int MAXP = 2000100;
const ll MOD = 1e9 + 7;

int N;
int pprime[MAXP];
int arr[MAXN];
int pord[MAXN];

map <int, int> pv;
map <int, int> nd;
int nvp[MAXP];
int nf[MAXP];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> N;
    for (int i = 2; i < MAXP; i++)
    {
        if (!pprime[i])
        {
            pprime[i] = i;
            for (int j = i; j < MAXP; j += i)
                pprime[j] = i;
        }
    }

    for (int i = 0; i < N; i++)
        cin >> arr[i];
    sort (arr, arr + N);
    reverse (arr, arr + N);

    int r = 0;
    for (int i = 0; i < N; i++)
    {
        int cp = arr[i];
        bool gadd = false;
        if (pv.find(cp) != pv.end())
        {
            cp--;
            while (cp > 1)
            {
                int np = pprime[cp], nc = 0;
                while (cp % np == 0)
                {
                    cp /= np;
                    nc++;
                }
                pv[np];
                if (pv[np] < nc)
                {
                    pv[np] = nc;
                    nd[np] = 1;
                    gadd = true;
                }
                else if (pv[np] == nc)
                    nd[np]++;
            }
            pord[i] = arr[i] - 1;
        }
        else
        {
            pv[cp] = 1;
            nd[cp] = 1;
            gadd = true;
            pord[i] = arr[i];
        }
        if (!gadd)
            r = 1;
    }
    for (pair <int, int> ppair : pv)
    {
        nvp[ppair.first] = ppair.second;
    }

    for (int i = 0; i < N; i++)
    {
        int cp = pord[i];

        bool gadd = false;
        while (cp > 1)
        {
            int np = pprime[cp], nc = 0;
            while (cp % np == 0)
            {
                cp /= np;
                nc++;
            }
            if (pv[np] == nc && nd[np] == 1) gadd = true;
        }
        if (!gadd) r = 1;
    }

    ll res = 1;
    for (pair <int, int> ppair : pv)
    {
        for (int i = 0; i < ppair.second; i++)
            res = (res * ppair.first) % MOD;
    }
    cout << (res + r) % MOD << "\n";
}

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 2e6+5, mod = 1e9+7;
int n, a[MX], pw[MX], cn[MX], bs[MX], f = 0;
ll res = 1;
bitset<MX> d;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);

	for (ll i = 2; i < MX; i++)
		if (!bs[i]) {
			bs[i] = i;
			for (ll j = i * i; j < MX; j += i)
				bs[j] = i;
		}

	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a+n, greater<int>());

	for (int i = 0; i < n; i++) {
		if (!pw[a[i]]) pw[a[i]] = 1, cn[a[i]] = 1;
		else {
			int x = a[i] - 1;

			while (x > 1) {
				int p = bs[x], e = 0;
				while (x % p == 0) x /= p, e++;

				if (e > pw[p]) pw[p] = e, cn[p] = 1;
				else if (e == pw[p]) cn[p]++;
			}

			d[i] = 1;
		}
	}

	for (int i = 0; i < n; i++)
		if (d[i]) {
			int x = a[i] - 1, g = 0;

			while (x > 1) {
				int p = bs[x], e = 0;
				while (x % p == 0) x /= p, e++;
				g |= e == pw[p] && cn[p] == 1;
			}

			f |= 1 - g;
		}

	for (int i = 2; i < MX; i++)
		while (pw[i]--)
			res = res * i % mod;

	cout << (res + f) % mod << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int) 1e9 + 23111992;
const ll LINF = (ll) 1e18 + 23111992;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ull icbrt(ull k) {ull r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

const int maxn = 2e6 + 5;
int sp[maxn];
int n;
int p[maxn];
vi cnt[maxn];
int g[maxn];

void volamtruyenkyii() {
    FOR(i, 1, maxn) sp[i] = i;
    FOR(i, 2, maxn) if (sp[i] == i) {
        for (int j = i; j < maxn; j += i) {
            chkmin(sp[j], i);
        }
    }
    cin >> n;
    map<int, int> hs;
    FOR(i, 0, n) cin >> p[i], hs[-p[i]]++;
    for (auto it : hs) {
        int p = -it.fi;
        if (!sz(cnt[p])) {
            cnt[p].pb(1);
        }
        else {
            g[p] = 1;
            int t = p - 1;
            map<int, int> f;
            while (t > 1) {
                f[sp[t]]++;
                t /= sp[t];
            }
            for (auto it : f) {
                cnt[it.fi].pb(it.se);
            }
        }
        if (it.se > 1) {
            int t = p - 1;
            map<int, int> f;
            while (t > 1) {
                f[sp[t]]++;
                t /= sp[t];
            }
            for (auto it : f) {
                cnt[it.fi].pb(it.se);
            }
        }
    }
    FOR(i, 2, maxn) cnt[i].pb(0);
    FOR(i, 2, maxn) sort(all(cnt[i]));
    int add = 0;
    for (auto it : hs) if (!add) {
        int p = -it.fi;
        if (g[p] || it.se > 1) {
            int t = p - 1;
            map<int, int> f;
            while (t > 1) {
                f[sp[t]]++;
                t /= sp[t];
            }
            int ok = 1;
            for (auto it : f) {
                if (lower_bound(all(cnt[it.fi]), it.se) - cnt[it.fi].begin() == sz(cnt[it.fi]) - 1) {
                    ok = 0;
                    break;
                }
            }
            if (ok) {
                add = 1;
            }
        }
        if (it.se > 2) {
            add = 1;
        }
    }
    int res = 1;
    FOR(i, 2, maxn) res = mult(res, fpow(i, cnt[i].back()));
    addmod(res, add);
    cout << res << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    volamtruyenkyii();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const ll mod = 1e9 + 7;
const int M = 2e6;

vector<pair<ll, ll> >divs[M + 1];

map<ll, ll>prm_cnts;
map<ll, bool> overkill;
bool bonus = false;

vector<ll> added;

void add(ll val){
	added.pb(val);
	for(auto& pp : divs[val]){
		if(prm_cnts[pp.ft] < pp.sd){
			prm_cnts[pp.ft] = pp.sd;
			overkill[pp.ft] = false;
		} else if(prm_cnts[pp.ft] == pp.sd){
			overkill[pp.ft] = true;
		}
	}
}

int main()
{
#ifndef LOCAL
	ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
	ll n; cin >> n;
	map<ll, ll>cnts;
	rep(_, 0, n){
		ll x; cin >> x;
		cnts[-x]++;
	}
	rep(i, 2, M + 1){
		if(SZ(divs[i]) == 0){
			for(ll j = 1; j * i <= M; j++){
				ll temp = j * i, mlt = 0;
				while(temp % i == 0){
					temp /= i;
					mlt++;
				}
				divs[j * i].pb({i, mlt});
			}
		}
	}
	for(auto& p : cnts){
		ll prm = -p.ft, mlt = p.sd;
		if(mlt > 2){
			bonus = true;
		}
		if(mlt >= 2){
			add(prm); add(prm - 1);
		} else {
			if(prm_cnts[prm] > 0){
				add(prm - 1);
			} else {
				add(prm);
			}
		}
	}
  	ll res = 1;
	for(auto& pp : prm_cnts){
		rep(_, 0, pp.sd){
			res = (res * pp.ft) % mod;
		}
	}
	bonus |= any_of(all(added), [&](ll v){ return all_of(all(divs[v]), [&](auto p){ return overkill[p.ft] or prm_cnts[p.ft] > p.sd;});});
	cout << (res + bonus) % mod<< "\n";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , __ = 2000007 , mo = 1000000007;

int isnp[__]={0},lasp[__]={0};

void fuck(int n=__-1)
{
	for(int i=2;i<=n;i++)
	{
		if(isnp[i])continue;
		lasp[i]=i;
		for(lint j=1ll*i*i;j<=n;j+=i)
		{
			isnp[j]=1;
			if(!lasp[j])lasp[j]=i;
		}
	}
}

map<int,pair<int,int>> mp;

void gmax(int who,int d)
{
	if(!who)return;
	if(mp[who].first<d)mp[who].second=0;
	if(mp[who].first<=d)mp[who].first=d,mp[who].second++;
}

void add(int x)
{
	int las=0,cnt=0;
	while(x>1)
	{
		int a=lasp[x];x/=a;
		if(las!=a)gmax(las,cnt),cnt=0;
		las=a,cnt++;
	}
	if(cnt)gmax(las,cnt);
}

int finder(int x)
{
	int las=0,cnt=0;
	while(x>1)
	{
		int a=lasp[x];x/=a;
		if(las!=a)
		{
			if(las && mp[las].first==cnt && mp[las].second==1)return 0;
			cnt=0;
		}
		las=a,cnt++;
	}
	if(las && mp[las].first==cnt && mp[las].second==1)return 0;
	return 1;
}

int n,val[_],fr[__]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	fuck();

	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty();
	sort(val+1,val+n+1,greater<int>());

	for(int i=1,j=1;i<=n;i=j+1)
	{
		j=i;
		while(j<n && val[i]==val[j+1])j++;
		add(val[i]);
	}

	for(int i=1,j=1;i<=n;i=j+1)
	{
		j=i;
		while(j<n && val[i]==val[j+1])j++;
		int cnt=j-i+1;
		if(cnt+finder(val[i])>=2)
		{
			if(cnt==1)
			{
				fr[val[i]]=1;
				if(mp[val[i]].first==1)mp[val[i]].second--;
			}
			add(val[i]-1);
		}
	}

	int temp=0;
	for(int i=1,j=1;i<=n;i=j+1)
	{
		j=i;
		while(j<n && val[i]==val[j+1])j++;
		int cnt=j-i+1;
		if(cnt+(cnt==1?fr[val[i]]:finder(val[i]))+finder(val[i]-1)>=3)temp=1;
	}

	lint ans=1;
	for(auto i:mp)while(i.second.first--)ans=ans*i.first%mo;
	if(temp)ans=(ans+1)%mo;

	cout<<ans<<lf;

	return 0;
}

#include <iostream>
#include <cassert>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int MAXN=2000111;
const int MOD=1000000007;

int sr;
int sum(int a, int b){
	sr=a+b;
	if(sr>=MOD)	sr-=MOD;
	return sr;
}

int mul(int a, int b){
	return (int)((1LL*a*b)%(1LL*MOD));
}

int pow(int a, int k){
	int ret=1, t=a;
	while(k){
		if(k&1){
			ret=mul(ret, t);
		}
		t=mul(t, t);
		k>>=1;
	}
	return ret;
}

int P[MAXN], Pc;
int Id[MAXN], Sp[MAXN];

int Mc[MAXN], Max[MAXN];

bool Vis(int a){
	return Mc[Id[a]];
}

void Push(int a, int t){
	a=Id[a];
	if(Max[a]<t)	{Max[a]=t;Mc[a]=1;}
	else if(Max[a]==t)	++Mc[a];
}

int Ans;

bool Ask(int a, int t){
	a=Id[a];
	if(Max[a]>t || Mc[a]>1){
		return true;
	}
	return false;
}

int N=2000000;

int A[MAXN];
bool _[MAXN];

int main(){

	for(int i=2;i<=N;++i)	Id[i]=1;
	for(int i=2;i<=N;++i){
		if(Id[i]){
			P[++Pc]=i;
			Id[i]=Pc;
			Sp[i]=i;
		}
		for(int j=1;j<=Pc && P[j]<=N/i;++j){
			Id[i*P[j]]=0;
			Sp[i*P[j]]=P[j];
			if(i%P[j]==0)	break;
		}
	}

	cin >> N;

	for(int i=1;i<=N;++i)	cin >> A[i];

	sort(A+1, A+N+1);

	for(int i=N, v;i>=1;--i){
		v=A[i];
		if(Vis(v)){
			_[i]=true;
			for(int k=v-1, c=0, p=Sp[k];k>1;){
				if(Sp[k]!=p){
					Push(p, c);
					c=0;p=Sp[k];
				}
				++c;
				k/=Sp[k];
				if(k==1)	Push(p, c);
			}
		}
		else	Push(v, 1);
	}

	Ans=1;
	for(int i=1;i<=Pc;++i)	if(Mc[i])	Ans=mul(Ans, pow(P[i], Max[i]));

	for(int i=N, v;i>=1;--i){
		v=A[i];
		bool w=true;
		if(_[i]){
			for(int k=v-1, c=0, p=Sp[k];k>1;){
				if(Sp[k]!=p){
					w&=Ask(p, c);
					c=0;p=Sp[k];
				}
				++c;
				k/=Sp[k];
				if(k==1)	w&=Ask(p, c);
			}
		}
		else	w&=Ask(v, 1);
		if(w){
			cout << Ans+1 << endl;
			return 0;
		}
	}

	cout << Ans << endl;

	return 0;
}

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
int p[200010];
bool vis[200010];
int q[2000010];
int c[2000010];
vector<int>d[2000010];
const int N=2000000;
void init()
{
	for(int i=2;i<=N;i++)
	{
		if(d[i].size())continue;
		for(int j=i;j<=N;j+=i)
			d[j].push_back(i);
	}
	return ;
}
void work(int x)
{
	for(int i=0;i<d[x].size();i++)
	{
		int y=d[x][i];
		int cnt=0,t=x;
		while(t%y==0)
		{
			t/=y;
			cnt++;
		}
		if(cnt>q[y])
		{
			q[y]=cnt;
			c[y]=1;
		}
		else if(cnt==q[y])
			c[y]++;
	}
	return ;
}
bool check(int x)
{
	for(int i=0;i<d[x].size();i++)
	{
		int y=d[x][i];
		int cnt=0,t=x;
		while(t%y==0)
		{
			t/=y;
			cnt++;
		}
		if(cnt==q[y]&&c[y]==1)return false;
	}
	return true;
}
const int Mod=1000000007;
int main()
{
	init();
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);
	sort(p+1,p+n+1);
	for(int i=n;i>=1;i--)
	{
		int x=p[i];
		if(!q[x]){
			q[x]=1;
			c[x]=1;
		}
		else{
			vis[i]=true;
			work(p[i]-1);
		}
	}
	int ans=1,add=0;
	for(int i=1;i<=n;i++)
		if(vis[i]&&check(p[i]-1))
			add=1;
	for(int i=2;i<=N;i++)
	{
		int t=q[i];
		for(int j=0;j<t;j++)
			ans=1ll*ans*i%Mod;
	}
	printf("%d\n",(ans+add)%Mod);
	return 0;
}

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e6 + 10;
int a[N];
int d[N];
int prime[N];
int key[N];
int cnt[N];
int cnt2[N];
int k = 0;
inline void init()
{
	for (int i = 2; i < N; i++)
	{
		if (!a[i])
			prime[++k] = i, d[i] = i;
		for (int j = 1; j <= k && (LL)i*prime[j] < N; j++)
		{
			d[i*prime[j]] = prime[j];
			a[i*prime[j]] = 1;
			if (i%prime[j] == 0)
				break;
		}
	}
	for (int i = 2; i < N; i++)
	{
		if (i / d[i] % d[i] == 0) key[i] = d[i] * key[i / d[i]];
		else key[i] = d[i];
	}
}

bool check(int x, int o = 0)
{
	int tot = 0;
	int cnt = 0;
	while (x > 1)
	{
		tot++;
		cnt += cnt2[key[x]] > 0;
		cnt2[key[x]] += o;
		x /= key[x];
	}
	return tot = cnt;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	init();
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	int ok = 0;
	for (int i = k; i > 0; i--)
	{
		int p = prime[i];
		if (cnt[p])
		{
			if (!check(p, 0))
			{
				check(p, 1), cnt[p]--;
			}
		}
		if (cnt[p] > 1) ok = 1;
		else if (p == 2 && cnt[p] > 0) ok = 1;
		if (cnt[p]) check(p - 1, 1);
	}
	for (int i = N - 1; i > 1; i--)
	{
		if (cnt2[i] <= 0)
		{
			continue;
		}
		int x = i;
		int sum = -cnt2[i];
		while (x > 1)
		{
			x /= d[x];
			cnt2[x] = -2;
		}
	}
	for (int i = 1; i <= k && !ok; i++)
	{
		int p = prime[i];
		if (cnt[p] == 0) continue;
		int cnt = 0;
		int tot = 0;
		int x = p - 1;
		while (x > 1)
		{
			tot++;
			if (cnt2[key[x]] != 1) cnt++;
			x /= key[x];
		}
		if (cnt == tot) ok = 1;
	}
	LL ans = 1;
	for (int i = N - 1; i > 1; i--)
	{
		if (cnt2[i] <= 0) continue;
		ans = ans * i%INF;
	}
	if (ok) ans++;
	if (ans >= INF) ans -= INF;
	printf("%lld\n", ans);
	return 0;
}

#include<cstdio>
const int MAX=2000010,mod=1000000007;
int n,m,mp[MAX],c[MAX],d[MAX],ds[MAX];
bool ty[MAX];
void upd(int i,int x){x>d[i]?d[i]=x,ds[i]=1:x==d[i]?ds[i]++:0;}
int main(){
	scanf("%d",&n);
	for(int p;n--;)scanf("%d",&p),c[p>m?m=p:p]++;
	for(int i=2;i<=m;i++)if(!mp[i])
		for(int j=i;j<=m;j+=i)if(!mp[j])mp[j]=i;
	int s=1,t=0;
	for(int i=m;i;i--)for(int j=c[i];j--;){
		if(d[i]){
			for(int x=i-1;x>1;){
				int p=mp[x],c=0;
				for(;x%p==0;x/=p)c++;
				for(int e=d[p];e<c;e++)s=1ll*s*p%mod;
				upd(p,c);
			}
			ty[i]=1;
		}
		else upd(i,1),s=1ll*s*i%mod;
	}
	for(int i=m;i;i--)if(ty[i]){
		bool fl=1;
		for(int x=i-1;x>1;){
			int p=mp[x],c=0;
			for(;x%p==0;x/=p)c++;
			if(c==d[p]&&ds[p]==1)fl=0;
		}
		if(fl)t=1;
	}
	printf("%d\n",(s+t)%mod);
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    vector<int> used(n, 0);

    vector<vector<pair<int,int> > > pfact(n);

    map<int,int> f;
    map<int,int> ffreq;

    for(int i = 0; i < n; i++){
        if(f[a[i]] == 0){
            f[a[i]] = 1;
            used[i] = 1;
            ffreq[a[i]] = 1;
        } else {
            a[i]--;
            for(int p = 2; p * p <= a[i]; p++){
                if(a[i] % p == 0){
                    int k = 0;
                    while(a[i] % p == 0){
                        a[i] /= p;
                        k++;
                    }
                    pfact[i].push_back({p, k});
                    if(k > f[p]){
                        f[p] = k;
                        ffreq[p] = 0;
                    }
                    if(k == f[p]){
                        ffreq[p]++;
                    }
                }
            }
            if(a[i] > 1){
                int p = a[i];
                int k = 1;
                pfact[i].push_back({p, k});
                if(k > f[p]){
                    f[p] = k;
                    ffreq[p] = 0;
                }
                if(k == f[p]){
                    ffreq[p]++;
                }
            }
        }
    }
    const LL MOD = 1000000007;
    LL num = 1;
    for(auto x : f){
        for(int j = 0; j < x.second; j++){
            num = (num * (LL) x.first) % MOD;
        }
    }
    int ok = 0;
    for(int i = 0; i < n; i++){
        if(!used[i]){
            int can_delete = 1;
            for(pair<int,int> x : pfact[i]){
                int p = x.first;
                int k = x.second;
                if(f[p] == k && ffreq[p] == 1){
                    can_delete = 0;
                }
            }
            if(can_delete == 1) ok = 1;
        }
    }
    num = (num + ok) % MOD;
    cout << num << '\n';
}

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=2e6+10;
const int mod=1e9+7;
int n,a[N],cnt[N],m[N],ans=1,P[N],val[N];
bool used[N];
void Lin_Sie(){
	used[1]=1;
	for(int i=2;i<N;i++){
		if(!used[i])P[++P[0]]=i,val[i]=i;
		for(int j=1;j<=P[0]&&1ll*i*P[j]<N;j++){
			used[i*P[j]]=1;
			val[i*P[j]]=P[j];
			if(i%P[j]==0)break;
		}
	}
}
int main()
{
	n=read();Lin_Sie();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
 	for(int i=n;i>=1;i--){
 		if(!cnt[a[i]])cnt[a[i]]++,m[a[i]]=1,ans=(1ll*ans*a[i])%mod;
 		else{
 	    int v=--a[i];
 	    while(v!=1){
    		int u=val[v],ls=0;
    		while(v%u==0)v/=u,ls++;
    		if(cnt[u]<ls){
    			for(int j=cnt[u]+1;j<=ls;j++)ans=(1ll*ans*u)%mod;
    			cnt[u]=ls;m[u]=1;
				}
				else if(cnt[u]==ls)m[u]++;
 			}
 		}
 	}
	for(int i=1;i<=n;i++){
		int v=a[i],flag=0;
		while(v!=1){
			int u=val[v],ls=0;
			while(v%u==0)v/=u,ls++;
			if(cnt[u]==ls&&m[u]==1)flag=1;
		}
		if(!flag){ans++;break;}
	}
	printf("%d\n",ans);
	return 0;
}

// [I didn't read the editorial or see any failed test cases]
// UPD: reverted to approximately 66793079, still get wrong answer...
// try looping forward int second iteration. I think this is strictly worse (smaller answer), however.
#ifndef LOCAL
#define NDEBUG
#endif
#include<cassert>
#include<iostream>
#include<algorithm>
#include<vector>

int const MOD=1000000007;
struct modular {
	int val;
	explicit constexpr operator int() const { return val; }
	constexpr modular():val(){}
#if MODULAR_LESS_EFFICIENT_BUT_EASIER_TO_CODE
	constexpr modular(int64_t v):val(int(v%MOD)){
		if(val<0)val+=MOD;
	}
#else
	constexpr modular(int v):val(v){
		assert(0<=v and v<MOD);
	}
#endif

#define COMPAREOP(OP) bool constexpr operator OP(modular b) const { return val OP b.val; }
	COMPAREOP(==) COMPAREOP(!=) COMPAREOP(<) COMPAREOP(>) COMPAREOP(<=) COMPAREOP(>=)
#undef COMPAREOP

	modular operator-() const { return modular(val ? MOD-val : 0); }
	modular constexpr& operator+=(modular m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	modular constexpr& operator-=(modular m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	modular constexpr& operator*=(modular m) { val = int((int64_t)val*m.val%MOD); return *this; }
	modular constexpr pow(int p) const {
		modular a=*this;
		modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	modular constexpr inv() const {
		int a=val,b=MOD, ax=1,bx=0;
		while(b){
			int q=a/b, t=a%b;
			a=b; b=t;
			t=ax-bx*q; ax=bx; bx=t;
		}
		assert(a==1);
		if(ax<0)ax+=MOD;
		return ax;
	}
	modular constexpr& operator/=(modular m) { return (*this) *= m.inv(); }

#define ARITHBINARYOP(OP) friend modular constexpr operator OP(modular a, modular b) { return a OP##= b; }
	ARITHBINARYOP(+) ARITHBINARYOP(-) ARITHBINARYOP(*) ARITHBINARYOP(/)
#undef ARITHBINARYOP
};

int main(){
	std::ios::sync_with_stdio(0);std::cin.tie(0);
	int n;std::cin>>n;
	std::vector<int> p(n);
	int maxp=0;
	for(int& pi:p){
		std::cin>>pi;
		maxp=std::max(maxp,pi);
	}

	std::vector<int> cnt(maxp+1);
	for(int pi:p)++cnt[pi];

	std::vector<int> minf(std::max(10,maxp+1));
	for(int p=2;p<(int)minf.size();++p)if(minf[p]==0){
		minf[p]=p;
		for(int64_t j=p*(int64_t)p;j<(int64_t)minf.size();j+=p)
			if(minf[j]==0)
				minf[j]=p;
	}

	bool add=std::any_of(begin(cnt),end(cnt),[](int x){return x>=3;});
	// let some ai=0, then out will be incremented by 1 (can be done at most once)
	// it should always be done when there's some prime appears more than 2 times

	std::vector<int> out_exp(maxp+1);

	std::vector<std::pair<int,int>> factors;
	auto const work_p_1=[&](int p){
		factors.clear();
		int x=p-1;
		while(x>1){
			int q=minf[x];
			int exp=0;
			do{ ++exp;x/=q; } while(x%q==0);
			factors.push_back({q,exp});
		}

		if(std::all_of(begin(factors),end(factors),[&out_exp](auto q_exp){
					auto [q,exp]=q_exp;
					return out_exp[q]>=exp;
					})){
			add=true;
		}else{
			for(auto [p,exp]:factors){
				out_exp[p]=std::max(out_exp[p],exp);
			}
		}
	};

	for(auto p=(int)cnt.size();p--;)if(cnt[p]>=1){
		out_exp[p]=1;
	}

	for(int p=0 /* or 2. It should not matter */;p<(int)cnt.size();++p)if(cnt[p]>=2){
		work_p_1(p);
	}

	modular out=1;
	for(int p=2;p<(int)out_exp.size();++p)if(out_exp[p]){
		assert(minf[p]==p);
		out*=modular(p).pow(out_exp[p]);
	}

	if(add)out+=1;
	std::cout<<(int)out<<'\n';
}

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
const int maxn = 2e6 + 100;
int n, x, H[maxn], F[maxn], M[maxn], a[maxn];
const int MOD = 1e9 + 7;
vector<int> V[maxn];
set<int> S;
long long ans = 1;

void wtf(int x){
    for(auto o : V[x]){
        int temp = x, tot = 0;
        while(temp % o == 0) temp /= o, tot++;
        /*if(H[o] == 1 && S.find(o) != S.end()) {
            //cout<<o<<endl;
            wtf(o-1);
            S.erase(o);
            S.insert(o-1);
        }*/
        for(int i = H[o]+1; i <= tot; i++) (ans *= o) %= MOD;
        if(H[o] <= tot){
            H[o] = max(H[o], tot);
            F[M[o]]--;
            M[o] = max(M[o], x);
            F[M[o]]++;
        }
    }
}

int main()
{
    for(int i = 2; i <= 2e6; i++){
        if(V[i].size() == 0)
            for(int j = 2; j*i <= 2e6; j++) V[i*j].push_back(i);
    }
    V[2].push_back(2);
    int f = 0, nt = 0;
    cin>>n;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a+1, a+1+n);
    for(int i = n; i >= 1; i--){
        x = a[i];
        H[x]++;
        if(H[x] == 1) {
            (ans *= x) %= MOD;
            M[x] = x;
            F[x]++;
            S.insert(x);
        }
        else if(H[x] >= 2) {
            x--;
            S.insert(x);
            long long rec = ans;
            wtf(x);
            if(rec == ans) f = 1;
        }
    }
    for(auto y : S) if(F[y] == 0) { cout<<ans+1<<endl; if(ans+1 == 327983056) cout<<y<<" "<<ans+1<<endl; return 0; }
    cout<<ans + f<<endl;
    return 0;
}

//>> OI Solution Info <<//
// Version: 2
// State: Progress
// Problem: Linear Congruential Generator
// ID: CF 1053D
// Timeline:
//   --- ~ --- Initialize
// Review:
//   ---
//>> End <<//
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 y_0
#define y1 y_1
#define yn y_n
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;
const int Mod=1000000007;

vector<int> prime;
bool nprime[2000005];
int index[2000005];

void preprocess(){
	memset(index,-1,sizeof index);
	nprime[0]=nprime[1]=true;
	for(int i=2;i<=2000000;i++){
		if(nprime[i])continue;
		for(int j=i+i;j<=2000000;j+=i)nprime[j]=true;
		index[i]=prime.size();
		prime.push_back(i);
	}
}

vector<pair<int,int> > factor(int x){
	vector<pair<int,int> > res;
	int curr=0;
	while((long long)prime[curr]*prime[curr]<=x){
		int cnt=0;
		while(x%prime[curr]==0)cnt++,x/=prime[curr];
		if(cnt!=0)res.push_back(make_pair(prime[curr],cnt));
		curr++;
	}
	res.push_back(make_pair(x,1));
	return res;
}

int fpow(int a,int b){
	if(b==0)return 1;
	long long res=fpow(a,b/2);
	(res*=res)%=Mod;
	return b%2==0?res:res*a%Mod;
}

int n,p[200005];
bool f[200005],used[150000],alt[150000];
int cnt[150000],mxid[150000];

int main(){
	preprocess();
	memset(mxid,-1,sizeof mxid);
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",p+i);
	sort(p,p+n);reverse(p,p+n);
	for(int i=0;i<n;i++){
		if(!used[index[p[i]]]){
			int ii=index[p[i]];
			used[ii]=f[i]=true;
			if(cnt[ii]<1)cnt[ii]=1,mxid[ii]=i,alt[ii]=false;
			else if(cnt[ii]==1)alt[ii]=true;
		}else{
			vector<pair<int,int> > res=factor(p[i]-1);
			for(size_t j=0;j<res.size();j++){
				int ii=index[res[j].first],ex=res[j].second;
				used[ii]=true;
				if(cnt[ii]<ex)cnt[ii]=ex,mxid[ii]=i,alt[ii]=false;
				else if(cnt[ii]==ex)alt[ii]=true;
			}
		}
	}
	long long res=1;
	for(size_t i=0;i<prime.size();i++){
		(res*=fpow(prime[i],cnt[i]))%=Mod;
	}
	bool fl=false;
	for(int i=0;i<n&&!fl;i++){
		if(f[i]){
			int ii=index[p[i]];
			if(mxid[ii]!=i||alt[ii])fl=true;
		}else{
			bool curr=true;
			vector<pair<int,int> > res=factor(p[i]-1);
			for(size_t j=0;j<res.size()&&curr;j++){
				int ii=index[res[j].first];
				if(mxid[ii]==i&&!alt[ii])curr=false;
			}
			if(curr)fl=true;
		}
	}
	if(fl)(res+=1)%=Mod;
	printf("%lld\n",res);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;
int p[200003] , N , lst[2000003]; bool nprm[2000003];
map < int , int > mx;

void init(){
	for(int i = 2 ; i <= 2e6 ; ++i)
		if(!nprm[i]){
			lst[i] = i;
			for(int j = i ; 1ll * j * i <= 2e6 ; ++j){
				nprm[i * j] = 1; if(!lst[i * j]) lst[i * j] = i;
			}
		}
}

bool add(int p){
	int pre = 0 , cnt = 0; bool flg = 0;
	while(p != 1){
		int t = lst[p]; p /= t;
		if(pre != t){
			if(mx[pre] < cnt){mx[pre] = cnt; flg = 1;}
			cnt = 0;
		}
		pre = t; ++cnt;
	}
	if(mx[pre] < cnt){mx[pre] = cnt; flg = 1;}
	return flg;
}

int main(){
	ios::sync_with_stdio(0); cin >> N; init();
	for(int i = 1 ; i <= N ; ++i) cin >> p[i];
	sort(p + 1 , p + N + 1 , [&](int p , int q){return p > q;}); int pos = 1 , tms = 1; bool flg = 0;
	while(pos <= N){
		int p1 = pos; while(p1 <= N && p[p1] == p[pos]) ++p1;
		int cnt = p1 - pos - add(p[pos]); if(cnt) cnt -= add(p[pos] - 1);
		if(cnt) flg = 1;
		pos = p1;
	}
	for(auto t : mx) while(t.second--) tms = 1ll * tms * t.first % MOD;
	cout << (tms + flg) % MOD;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 2000007;
const int MOD = 1000000007;

int n;
int c[MAXN], un[MAXN];
bool isp[MAXN];

void init ();
void input ();
void work ();

int main()
{
	init();
	input();
	work();
}

void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d", &n );
	int x;
	lpi ( i, 1, n ){
		scanf ( "%d", &x );
		++c[x];
	}
}

void work ()
{
	// main work

	lp ( i, 1, MAXN ) if ( c[i] >= 2 ) ++c[i-1], --c[i];

	int ans = 1;
	int fc;
	INIT ( isp, true );
	fill ( un, un+MAXN, 1 );
	isp[0] = isp[1] = false;
	lp ( i, 2, MAXN ){
		if ( isp[i] ){
			if ( SC ( LL, i ) * i < MAXN ) for ( int j = i * i; j < MAXN; j += i ) isp[j] = false;
			for ( int t = i; t < MAXN; ( SC ( LL, t ) * i < MAXN ) ? ( t *= i ) : ( t = INF ) ){
				fc = 0;
				for ( int j = t; j < MAXN; j += t ){
					if ( c[j] ){
						++fc;
						if ( fc >= 2 ) break;
					}
				}
				if ( fc >= 2 ) for ( int j = t; j < MAXN; j += t ) if ( ( j / t ) % i ) un[j] *= t;
				if ( fc ) ans = SC ( LL, ans ) * i % MOD;
			}
		}
	}

	bool flag = false;
	lp ( i, 1, MAXN ){
		if ( c[i] >= 2 || ( c[i] && un[i] == i ) ){
			flag = true;
			break;
		}
	}
	if ( flag ) ++ans;

	cout << ans << endl;
}

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db long double
#define pii pair<int,int>
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define inf ((1<<30)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
const int mo=1000000007;
const int N=200005,M=2000000;
int n,jdb,a[N],fl[M+5],cnt[M+5],ans=1;
int c[3];
void solveprb(int x,int cnt){
	c[0]=2; c[1]=x; c[2]=x-1;
	sort(c,c+3);
	for (int i=2;i>=0&&cnt;i--,cnt--)
		ans=1ll*ans*c[i]%mo;
}
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]),cnt[a[i]]++;
	For(i,1,M) if (cnt[i]) solveprb(i,cnt[i]);
	printf("%d",ans);
}

#include<bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;
const int MX = 2000010;
const int MN = 200010;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}

vector<int> pr;
int pchk[MX];

void sieve() {
    for(int i = 2; i < MX; i++) {
        if(!pchk[i]) {
            pr.push_back(i);
            pchk[i] = i;
        }
        for(int j = 0; j < pr.size() && i * pr[j] < MX; j++) {
            pchk[ i * pr[j] ] = pr[j];
            if(i % pr[j] == 0) break;
        }
    }
}

int N;
int cnt[MX], pcnt[MX];

int main() {
    sieve();

    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        int t; scanf("%d", &t);
        cnt[t]++;
    }

    for(int i = 0; i < pr.size(); i++) {
        if(!cnt[ pr[i] ]) continue;
        pcnt[ pr[i] ] = 1;
        if(cnt[ pr[i] ] > 1) {
            int t = pr[i] - 1;
            int p = -1;
            int c = 0;
            while(t != 1) {
                if(p != pchk[t]) {
                    if(p != -1) pcnt[p] = max(pcnt[p], c);
                    p = pchk[t];
                    c = 0;
                }
                c++;
                t /= pchk[t];
            }
            if(p != -1) pcnt[p] = max(pcnt[p], c);
        }
    }
    int ans = 1;
    for(int i = 0; i < pr.size(); i++) {
        ans = 1LL * ans * exp(pr[i], pcnt[ pr[i] ]) % mod;
    }
    printf("%d", ans);
}

#include <iostream>
#include <cassert>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int MAXN=2000111;
const int MOD=1000000007;

int sr;
int sum(int a, int b){
	sr=a+b;
	if(sr>=MOD)	sr-=MOD;
	return sr;
}

int mul(int a, int b){
	return (int)((1LL*a*b)%(1LL*MOD));
}

int pow(int a, int k){
	int ret=1, t=a;
	while(k){
		if(k&1){
			ret=mul(ret, t);
		}
		t=mul(t, t);
		k>>=1;
	}
	return ret;
}

int P[MAXN], Pc;
int Id[MAXN], Sp[MAXN];

int Mc[MAXN], Max[MAXN];

bool Vis(int a){
	return Mc[Id[a]];
}

void Push(int a, int t){
	a=Id[a];
	if(Max[a]<t)	{Max[a]=t;Mc[a]=1;}
	else if(Max[a]==t)	++Mc[a];
}

int Ans;

void Ask(int a, int t){
	a=Id[a];
	if(Max[a]>t || Mc[a]>1){
		cout << sum(Ans, 1) << endl;
		exit(0);
	}
	return;
}

int N=2000000;

int A[MAXN];
bool _[MAXN];

int main(){

	for(int i=2;i<=N;++i)	Id[i]=1;
	for(int i=2;i<=N;++i){
		if(Id[i]){
			P[++Pc]=i;
			Id[i]=Pc;
			Sp[i]=i;
		}
		for(int j=1;j<=Pc && P[j]<=N/i;++j){
			Id[i*P[j]]=0;
			Sp[i*P[j]]=P[j];
			if(i%P[j]==0)	break;
		}
	}

	cin >> N;

	for(int i=1;i<=N;++i)	cin >> A[i];

	sort(A+1, A+N+1);

	for(int i=N, v;i>=1;--i){
		v=A[i];
		if(Vis(v)){
			_[i]=true;
			for(int k=v-1, c=0, p=Sp[k];k>1;){
				if(Sp[k]!=p){
					Push(p, c);
					c=0;p=Sp[k];
				}
				++c;
				k/=Sp[k];
				if(k==1)	Push(p, c);
			}
		}
		else	Push(v, 1);
	}

	Ans=1;
	for(int i=1;i<=Pc;++i)	if(Mc[i])	Ans=mul(Ans, pow(P[i], Max[i]));

	for(int i=N, v;i>=1;--i){
		v=A[i];
		if(_[i]){
			if(v==2){
				cout << Ans+1 << endl;
				return 0;
			}
			for(int k=v-1, c=0, p=Sp[k];k>1;){
				if(Sp[k]!=p){
					Ask(p, c);
					c=0;p=Sp[k];
				}
				++c;
				k/=Sp[k];
				if(k==1)	Ask(p, c);
			}
		}
		else	Ask(v, 1);
	}

	cout << Ans << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,C[2000005];
int go[2000005];
vector<int>cnt[2000005];
vector<P>vecc[600005];;
int main(){
	scanf("%d",&n);
	for(int i=2;i<=2000000;i++){
		if(go[i]) continue;
		go[i] = i;
		for(int j=i+i;j<=2000000;j+=i){
			go[j] = i;
		}
	}
	for(int i=1;i<=n;i++){
		int w;
		scanf("%d",&w);
		C[w]++;
	}
	int num = 0;
	bool ok = 0;
	for(int i=2000000;i>=2;i--){
		if(C[i] == 0) continue;
		if(C[i] == 1){
			if(cnt[i].empty()){
				cnt[i].pb(1);
				vecc[num++].pb(mp(i,1));
			}
			else{
				int cur = i-1;
    			vector<int>vec;
    			while(cur > 1){
    				vec.pb(go[cur]);
    				cur /= go[cur];
    			}
    			SORT(vec);
    			cur = -1;
    			int ccnt = 0;
    			for(int j=0;j<vec.size();j++){
    				if(j == 0){
    					cur = vec[j];
    					ccnt = 1;
    					continue;
    				}
    				if(cur != vec[j]){
    					cnt[cur].pb(ccnt);
    					vecc[num].pb(mp(cur,ccnt));
    					cur = vec[j];
    					ccnt = 1;
    				}
    				else ccnt++;
    			}
    			cnt[cur].pb(ccnt);
    			vecc[num++].pb(mp(cur,ccnt));
			}
		}
		else {
			if(C[i] > 2) ok = 1;
			cnt[i].pb(1);
			vecc[num++].pb(mp(i,1));
			int cur = i-1;
			vector<int>vec;
			while(cur > 1){
				vec.pb(go[cur]);
				cur /= go[cur];
			}
			SORT(vec);
			cur = -1;
			int ccnt = 0;
			for(int j=0;j<vec.size();j++){
				if(j == 0){
					cur = vec[j];
					ccnt = 1;
					continue;
				}
				if(cur != vec[j]){
					cnt[cur].pb(ccnt);
					vecc[num].pb(mp(cur,ccnt));
					cur = vec[j];
					ccnt = 1;
				}
				else ccnt++;
			}
			cnt[cur].pb(ccnt);
			vecc[num++].pb(mp(cur,ccnt));
		}
	}
	for(int i=2;i<=2000000;i++){
		SORT(cnt[i]);
		reverse(cnt[i].begin(),cnt[i].end());
	}
	for(int i=0;i<num;i++){
		for(int j=0;j<vecc[i].size();j++){
			int A = vecc[i][j].fi, B = vecc[i][j].sc;
			if(cnt[A].size() == 1 || cnt[A][1] < B) goto fail;
		}
		ok = 1; break;
		fail:;
	}
	ll ans = 1;
	for(int i=2;i<=2000000;i++){
		if(cnt[i].size()) rep(j,cnt[i][0]) ans = ans*1LL*i%mod;
	}
	if(ok) ans = (ans+1LL)%mod;
	cout<<ans<<endl;
}

#include<bits/stdc++.h>

const int N = 2000010;
const int moder = 1e9 + 7;

int min[N];
std::vector <int> prime;
bool vis[N];
int max[N], cnt[N];

int powermod(int a, int exp){
    int ret = 1;
    for ( ; exp > 0; exp >>= 1){
        if (exp & 1){
            ret = 1ll * ret * a % moder;
        }
        a = 1ll * a * a % moder;
    }
    return ret;
}

void init(){
    for (int i = 2; i < N; ++ i){
        if (!min[i]){
            min[i] = i;
            prime.push_back(i);
        }
        for (int j = 0, sz = prime.size(); j < sz && i * prime[j] < N; ++ j){
            min[i * prime[j]] = prime[j];
            if (i % prime[j] == 0){
                break;
            }
        }
    }
}

bool flag = false;

void add(int x){
    bool flag1 = false;
    while (x > 1){
        int tmp = min[x], cnt = 0;
        while (x % tmp == 0){
            ++ cnt;
            x /= tmp;
        }
        if (max[tmp] < cnt){
            flag1 = true;
            max[tmp] = cnt;
        }
    }
    if (!flag1){
        flag = true;
    }
}

int main(){
    init();
    int n;
    scanf("%d", &n);
    for (int i = 0, p; i < n; ++ i){
        scanf("%d", &p);
        ++ cnt[p];
    }
    for (int i = 0; i < N; ++ i){
        if (cnt[i] >= 3){
            flag = true;
        }
        else if (cnt[i] >= 2){
            add(i);
            add(i - 1);
        }
    }
    for (int i = 0; i < N; ++ i){
        if (cnt[i] == 1){
            if (max[i]){
                add(i - 1);
            }
            else{
                add(i);
            }
        }
    }
    int ans = 1;
    for (int i = 0; i < N; ++ i){
        if (i == min[i]){
            ans = 1ll * ans * powermod(i, max[i]) % moder;
        }
    }
    ans += flag;
    ans -= ans >= moder ? moder : 0;
    printf("%d\n", ans);
    return 0;
}

//pll test(ll x, ll a, ll b, ll p){
//    x %= p;
//    a %= p;
//    b %= p;
//    map<int,int> last;
//    last[x] = 0;
//    for(int i = 1;; ++i){
//        x = (x*a+b)%p;
//        if(last.count(x))
//            return {i-last[x],last[x]};
//        last[x] = i;
//    }
//}
//void _(){
//    int n;
//    cin >> n;
//    vi arr(n);
//    cin >> arr;
//    vector<vpii> interesting;
//    set<int> seen;
//    set<int> seen2;
//    for(int x : arr){
//        if(seen.count(x) == 0){
//            interesting.pb({{x,1}});
//            seen.insert(x);
//        }
//        else if(seen2.count(x) == 0){
//            auto stuff = factorize(x-1);
//            map<int,int> cnt;
//            for(int x : stuff)
//                cnt[x]++;
//            vpii add;
//            for(auto _ : cnt)
//                add.pb({_.X,_.Y});
//            interesting.pb(add);
//            seen2.insert(x);
//        }
//    }
//    map<int,int> cnt_ans;
//    for(auto _ : interesting)
//        for(auto _  : _)
//            cnt_ans[_.X] = max(cnt_ans[_.X],_.Y);
//    vvi solvings;
//    vi cnt_solves(2e6+5);
//    for(auto _ : interesting){
//        vi solves;
//        for(auto _  : _)
//            if(_.Y == cnt_ans[_.X])
//                solves.pb(_.X);
//        solvings.pb(solves);
//        for(int x : solves)
//            cnt_solves[x]++;
//    }
//    bool flag = 0;
//    for(auto _ : solvings){
//        bool needed = false;
//        for(int x : _)
//            if(cnt_solves[x] == 1)
//                needed = true;
//        if(!needed)
//            flag = true;
//    }
//    ll ans = 1;
//    for(auto _ : cnt_ans)
//        rep(i,1,_.Y)
//            ans = (ans*_.X)%MOD;
//
//    if(flag)
//        ans = (ans+1)%MOD;
//    print(ans);
//}
#include <stack>
#include <map>
#include <cmath>
#include <set>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define X first
#define Y second
#define T1 template<typename T> static
#ifndef __SIZEOF_INT128__
#define __int128 long long
#endif
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const ll MOD = 1e9 + 7;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
template<typename T, typename SFINAE = void> struct bigger_type{};
template<typename T> using bigger_type_t = typename bigger_type<T>::type;
template<typename T> struct bigger_type<T, typename enable_if<is_integral<T>::value && is_signed<T>::value && sizeof(T) == 4>::type>{using type = long long;};
template<typename T> struct bigger_type<T, typename enable_if<is_integral<T>::value && !is_signed<T>::value && sizeof(T) == 4>::type>{using type = unsigned long long;};
template<typename T> struct bigger_type<T, typename enable_if<is_integral<T>::value && is_signed<T>::value && sizeof(T) == 8>::type>{using type = __int128;};
template<typename T> struct bigger_type<T, typename enable_if<is_integral<T>::value && !is_signed<T>::value && sizeof(T) == 8>::type>{using type = unsigned __int128;};
template<typename int_t = unsigned long long>
struct ModInt{
    static inline int_t add(int_t const&a, int_t const&b, int_t const&mod){
        int_t ret = a+b;
        if(ret>=mod) ret-=mod;
        return ret;
    }
    static inline int_t sub(int_t const&a, int_t const&b, int_t const&mod){
        return add(a, mod-b);
    }
    static inline int_t mul(int_t const&a, int_t const&b, int_t const&mod){
        return a*static_cast<bigger_type_t<int_t>>(b)%mod;
    }
    static inline int_t pow(int_t const&a, int_t const&b, int_t const&mod){
        int_t ret = 1;
        int_t base = a;
        for(int i=0;b>>i;++i){
            if((b>>i)&1) ret = mul(ret, base, mod);
            base = mul(base, base, mod);
        }
        return ret;
    }
};
T1 bool miller_rabin_single(T const&x, T base){
    static_assert(is_integral<T>::value);
    if(x<T(4)) return x>T(1);
    if(x%2 == 0) return false;
    base%=x;
    if(base == 0) return true;
    T xm1 = x-1;
    int j = 1;
    T d = xm1/2;
    while(d%2 == 0){ // could use __builtin_ctz
        d/=2;
        ++j;
    }
    T t = ModInt<T>::pow(base, d, x);
    if(t==T(1) || t==T(xm1)) return true;
    for(int k=1;k<j;++k){
        t = ModInt<T>::mul(t, t, x);
        if(t == xm1) return true;
        if(t<=1) break;
    }
    return false;
}
T1 bool miller_rabin_multi(T const&){return true;}
template<typename T, typename... S>
bool miller_rabin_multi(T const&x, T const&base, S const&...bases){
    static_assert(is_integral<T>::value);
    if(!miller_rabin_single(x, base)) return false;
    return miller_rabin_multi(x, bases...);
}
T1 bool miller_rabin(T const&x){
    static_assert(is_integral<T>::value);
    if(x < 316349281) return miller_rabin_multi(x, T(11000544), T(31481107));
    if(x < 4759123141ull) return miller_rabin_multi(x, T(2), T(7), T(61));
    return miller_rabin_multi(x, T(2), T(325), T(9375), T(28178), T(450775), T(9780504), T(1795265022));
}
T1 T isqrt(T const&x){
    static_assert(is_integral<T>::value);
    assert(x>=T(0));
    T ret = static_cast<T>(sqrtl(x));
    while(ret>0 && ret*ret>x) --ret;
    while(x-ret*ret>2*ret)
        ++ret;
    return ret;
}
T1 T icbrt(T const&x){
    static_assert(is_integral<T>::value);
    assert(x>=T(0));
    T ret = static_cast<T>(cbrt(x));
    while(ret>0 && ret*ret*ret>x) --ret;
    while(x-ret*ret*ret>3*ret*(ret+1))
        ++ret;
    return ret;
}
static uint64_t squfof_iter_better(uint64_t const&x, uint64_t const&k, uint64_t const&it_max, uint32_t cutoff_div){
    static vector<uint16_t> saved;
    if(__gcd((uint64_t)k, x)!=1) return __gcd((uint64_t)k, x);
    //cerr << "try: " << x << " " << k << "\n";
    saved.clear();
    uint64_t scaledn = k*x;
    if(scaledn>>62) return 1;
    uint32_t sqrtn = isqrt(scaledn);
    uint32_t cutoff = isqrt(2*sqrtn)/cutoff_div;
    uint32_t q0 = 1;
    uint32_t p1 = sqrtn;
    uint32_t q1 = scaledn-p1*p1;
    if(q1 == 0){
        uint64_t factor = __gcd(x, (uint64_t)p1);
        return factor==x ? 1:factor;
    }
    uint32_t multiplier = 2*k;
    uint32_t coarse_cutoff = cutoff * multiplier;
    //cerr << "at: " << multiplier << "\n";
    uint32_t i, j;
    uint32_t p0 = 0;
    uint32_t sqrtq = 0;
    for(i=0;i<it_max;++i){
        uint32_t q, bits, tmp;
        tmp = sqrtn + p1 - q1;
        q = 1;
        if (tmp >= q1)
            q += tmp / q1;
        p0 = q * q1 - p1;
        q0 = q0 + (p1 - p0) * q;
        if (q1 < coarse_cutoff) {
            tmp = q1 / __gcd(q1, multiplier);
            if (tmp < cutoff) {
                saved.push_back((uint16_t)tmp);
            }
        }
        bits = 0;
        tmp = q0;
        while(!(tmp & 1)) {
            bits++;
            tmp >>= 1;
        }
        if (!(bits & 1) && ((tmp & 7) == 1)) {
            sqrtq = (uint32_t)isqrt(q0);
            if (sqrtq * sqrtq == q0) {
                for(j=0;j<saved.size();++j){
                    if(saved[j] == sqrtq) break;
                }
                if(j == saved.size()) break;
                //else cerr << "skip " << i << "\n";;
            }
        }
        tmp = sqrtn + p0 - q0;
        q = 1;
        if (tmp >= q0)
            q += tmp / q0;
        p1 = q * q0 - p0;
        q1 = q1 + (p0 - p1) * q;
        if (q0 < coarse_cutoff) {
            tmp = q0 / __gcd(q0, multiplier);
            if (tmp < cutoff) {
                saved.push_back((uint16_t) tmp);
            }
        }
    }
    if(sqrtq == 1) { return 1;}
    if(i == it_max) { return 1;}
    q0 = sqrtq;
    p1 = p0 + sqrtq * ((sqrtn - p0) / sqrtq);
    q1 = (scaledn - (uint64_t)p1 * (uint64_t)p1) / (uint64_t)q0;
    for(j=0;j<it_max;++j) {
        uint32_t q, tmp;
        tmp = sqrtn + p1 - q1;
        q = 1;
        if (tmp >= q1)
            q += tmp / q1;
        p0 = q * q1 - p1;
        q0 = q0 + (p1 - p0) * q;
        if (p0 == p1) {
            q0 = q1;
            break;
        }
        tmp = sqrtn + p0 - q0;
        q = 1;
        if (tmp >= q0)
            q += tmp / q0;
        p1 = q * q0 - p0;
        q1 = q1 + (p0 - p1) * q;
        if (p0 == p1)
            break;
    }
    if(j==it_max) {cerr << "RNG\n"; return 1;} // random fail
    uint64_t factor = __gcd((uint64_t)q0, x);
    if(factor == x) factor=1;
    return factor;
}
uint64_t squfof(uint64_t const&x){
    static array<uint32_t, 16> multipliers{1, 3, 5, 7, 11, 3*5, 3*7, 3*11, 5*7, 5*11, 7*11, 3*5*7, 3*5*11, 3*7*11, 5*7*11, 3*5*7*11};
    uint64_t cbrt_x = icbrt(x);
    if(cbrt_x*cbrt_x*cbrt_x == x) return cbrt_x;
    //uint32_t iter_lim = isqrt(isqrt(x))+10;
    uint32_t iter_lim = 300;
    for(uint32_t iter_fact = 1;iter_fact<20000;iter_fact*=4){
        for(uint32_t const&k : multipliers){
            if(numeric_limits<uint64_t>::max()/k<=x) continue; //would overflow
            uint32_t const it_max = iter_fact*iter_lim;
            uint64_t factor = squfof_iter_better(x, k, it_max, 1);
            if(factor==1 || factor==x) continue;
            return factor;
        }
    }
    cerr << "failed to factor: " << x << "\n";
    assert(0);
    return 1;
}
T1 vector<T> factorize(T x){
    static_assert(is_integral<T>::value);
    assert(x >= T(1));
    vector<T> ret;
    const uint32_t trial_limit = 5000;
    auto trial = [&](int i){while(x%i == 0){x/=i; ret.push_back(i);}};
    trial(2); trial(3);
    for(uint32_t i=5, j=2;i<=trial_limit && i*i <= x;i+=j, j=6-j){
        trial(i);
    }
    if(x > 1 && trial_limit*trial_limit >= x)
        trial(x);
    if(x>1){
        static stack<T> s;
        s.push(x);
        while(!s.empty()){
            x = s.top(); s.pop();
            if(!miller_rabin(x)){
                T factor = squfof(x);
                if(factor == 1 || factor == x){assert(0); return ret;}
                s.push(factor);
                s.push(x/factor);
            } else {
                ret.push_back(x);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
pll test(ll x, ll a, ll b, ll p){
    x %= p;
    a %= p;
    b %= p;
    map<int,int> last;
    last[x] = 0;
    for(int i = 1;; ++i){
        x = (x*a+b)%p;
        if(last.count(x))
            return {i-last[x],last[x]};
        last[x] = i;
    }
}
void _(){
    int n;
    cin >> n;
    vi arr(n);
    cin >> arr;
    vector<vpii> interesting;
    set<int> seen;
    set<int> seen2;
    for(int x : arr){
        if(seen.count(x) == 0){
            interesting.pb({{x,1}});
            seen.insert(x);
        }
        else if(seen2.count(x) == 0){
            auto stuff = factorize(x-1);
            map<int,int> cnt;
            for(int x : stuff)
                cnt[x]++;
            vpii add;
            for(auto _ : cnt)
                add.pb({_.X,_.Y});
            interesting.pb(add);
            seen2.insert(x);
        }
    }
    map<int,int> cnt_ans;
    for(auto _ : interesting)
        for(auto _  : _)
            cnt_ans[_.X] = max(cnt_ans[_.X],_.Y);
    vvi solvings;
    vi cnt_solves(2e6+5);
    for(auto _ : interesting){
        vi solves;
        for(auto _  : _)
            if(_.Y == cnt_ans[_.X])
                solves.pb(_.X);
        solvings.pb(solves);
        for(int x : solves)
            cnt_solves[x]++;
    }
    bool flag = 0;
    for(auto _ : solvings){
        bool needed = false;
        for(int x : _)
            if(cnt_solves[x] == 1)
                needed = true;
        if(!needed)
            flag = true;
    }
    ll ans = 1;
    for(auto _ : cnt_ans)
        rep(i,1,_.Y)
            ans = (ans*_.X)%MOD;
    if(flag)
        ans = (ans+1)%MOD;
    print(ans);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}

#include<bits/stdc++.h>
using namespace std;
int p[2000001];
int num[2000001];
const int mod = 1e9 + 7;
int s[2000001];
void pre()
{
    for(int i = 2;i <= 2000000;i++){
        if(!p[i]){
            p[i] = i;
            for(int j = i*2;j <= 2000000;j += i){
                if(!p[j]) p[j] = i;
            }
        }
    }
    return;
}
bool sp(int x)
{
    bool sq = 0;
    while(x > 1){
        int j = p[x];int ned = 0;
        while(p[x] == j && x > 1){
            ned++;x /= p[x];
        }
        if(ned > s[j]) sq = 1;
        s[j] = max(s[j] , ned);
    }
    return sq;
}
int power(int a,int b)
{
    int ans = 1;
    while(b){
        if(b & 1) ans = (1LL * ans * a) % mod;
        a = (1LL * a *a) %mod;b >>= 1;
    }
    return ans;
}
bool chk(int x)
{
    bool sq = 0;
    while(x > 1){
        int j = p[x];int ned = 0;
        while(p[x] == j && x > 1){
            ned++;x /= p[x];
        }
        if(ned == s[j]) sq = 1;
    }
    return sq;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int n;scanf("%d",&n);
    pre();
    for(int i = 1;i <= n;i++){
        int x;
        scanf("%d",&x);num[x]++;
    }
    int f = 0;
    for(int i = 2000000;i >= 1;i--){
        if(num[i] >= 2){
            if(sp(i - 1) == 0){
                f = 1;
            }
            else if(s[i] >= 1) f = 1;
            s[i] = max(s[i] , 1);
            if(num[i] >= 3) f = 1;
        }
    }
    for(int i = 2000000;i >= 1;i--){
        if(num[i] == 1){
            if(s[i]){
                if(sp(i - 1) == 0) f = 1;
            }
            else s[i] = 1;
        }
        else if(num[i] > 1){
            if(chk(i - 1) == 0) f = 1;
        }
    }
    int ans = 1;
    for(int i = 1;i <= 2000000;i++){
        if(s[i]) ans = (1LL * ans * power(i , s[i])) % mod;
    }
    cout<<(ans+f)%mod<<endl;
    return 0;
}

#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#define MOD 1000000007

int p[200000];
int f[2000001];
int num[2000001],yes[2000001],type[200000];
int ways[2000001];
vpii factor(int x) {
    vpii v;
    while (x > 1) {
        int ff = f[x],c = 0;
        while ((x % ff) == 0) c++,x /= ff;
        v.pb(mp(ff,c));
    }
    return v;
}
queue<int> Q;
int done[2000001];
int main() {
    int i;
    int n;
    scanf("%d",&n);
    memset(yes,-1,sizeof(yes));
    for (i = 0; i < n; i++) scanf("%d",&p[i]),yes[p[i]] = i;
    sort(p,p+n);

    int j;
    for (i = 2; i <= 2000000; i++) {
        if (f[i] == 0) {
            for (j = i; j <= 2000000; j += i) f[j] = i;
        }
    }
    for (i = 1; i < n; i++) {
        if (p[i-1] == p[i]) {
            num[p[i]] = max(num[p[i]],1);
            vpii v = factor(p[i]-1);
            for (j = 0; j < v.size(); j++) num[v[j].first] = max(num[v[j].first],v[j].second),Q.push(v[j].first);
            type[i-1] = 1,type[i] = 2,yes[p[i]] = -1,done[p[i]] = 1;
        }
    }
    while (!Q.empty()) {
        int u = Q.front();
        Q.pop();

        if (yes[u] == -1) done[u] = 1;
        if (done[u]) continue;
        done[u] = 1;
        vpii v = factor(u-1);
        for (i = 0; i < v.size(); i++) num[v[i].first] = max(num[v[i].first],v[i].second),Q.push(v[i].first);
        type[yes[u]] = 2;
    }
    for (i = 0; i < n; i++) {
        if (!done[p[i]]) num[p[i]] = max(num[p[i]],1),type[i] = 1;
    }
    for (i = 0; i < n; i++) {
        vpii v = factor((type[i] == 2) ? (p[i]-1):p[i]);
        for (j = 0; j < v.size(); j++) {
            if (num[v[j].first] == v[j].second) ways[v[j].first]++;
        }
    }
    int t = 0;
    for (i = 0; i < n; i++) {
        vpii v = factor((type[i] == 2) ? (p[i]-1):p[i]);
        int useful = 0;
        for (j = 0; j < v.size(); j++) {
            if ((num[v[j].first] == v[j].second) && (ways[v[j].first] == 1)) useful = 1;
        }
        if (!useful) {
            t = 1;
            break;
        }
    }
    LLI ans = 1;
    for (i = 2; i <= 2000000; i++) {
        if (num[i] > 0) {
            for (j = 0; j < num[i]; j++) ans *= i,ans %= MOD;
        }
    }
    if (t) ans++,ans %= MOD;
    printf("%I64d\n",ans);

    return 0;
}

#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define right sefudermano
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 2e6 + 100, M = 1e9 +7;
int cnt[N];
int used[N];

bool mark[N];
int prime[N];

void crivo(){
  for(int i=2;i<N;i++){
    if(!mark[i]){
      prime[i] = i;
      for(int j = i+i;j<N;j+=i){
        mark[j] = 1;
        prime[j] = i;
      }
    }
  }
}

ll d[N];

ll lcm(){
  ll ans = 1;
  for(int i=2;i<N;i++){
    if(cnt[i]==0)continue;
    int x = i;
    while(x>1){
      int p = prime[x];
      int k=0;
      while(x%p==0){
        x/=p;
        k++;
      }
      d[p]+=k * cnt[i];
    }
  }

  for(int i=1;i<N;i++){
    ans = (ans * exp(i,d[i],M))%M;
  }
  return ans;
}

int32_t main(){
  fastio;
  crivo();
  int n;
  cin >> n;
  int pp=0;
  for(int i=1;i<=n;i++){
    int p;
    cin>>p;
    if(p==2){
      if(!used[p])cnt[2]++;
      else{
        pp = 1;
      }
      used[p]++;
    }else{
      if(used[p]==0){
        cnt[p]++;
        used[p] = 1;
      }else if(used[p]==1){
        cnt[p-1]++;
        used[p] = 2;
      }else if(used[p]==2){
        pp =1;
        used[p] = 3;
      }
    }
  }

  ll ans = lcm();

  ans = mod(ans + pp,M);

  cout << ans << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#define MOD 1000000007

int p[200000];
int f[2000001];
int num[2000001],yes[2000001];
vpii factor(int x) {
    vpii v;
    while (x > 1) {
        int ff = f[x],c = 0;
        while ((x % ff) == 0) c++,x /= ff;
        v.pb(mp(ff,c));
    }
    return v;
}
queue<int> Q;
int done[2000001];
int main() {
    int i;
    int n;
    scanf("%d",&n);
    for (i = 0; i < n; i++) scanf("%d",&p[i]),yes[p[i]] = 1;
    sort(p,p+n);

    int j;
    for (i = 2; i <= 2000000; i++) {
        if (f[i] == 0) {
            for (j = i; j <= 2000000; j += i) f[j] = i;
        }
    }
    for (i = 1; i < n; i++) {
        if (p[i-1] == p[i]) {
            num[p[i]] = max(num[p[i]],1);
            vpii v = factor(p[i]-1);
            for (j = 0; j < v.size(); j++) num[v[j].first] = max(num[v[j].first],v[j].second),Q.push(v[j].first);
        }
    }
    while (!Q.empty()) {
        int u = Q.front();
        Q.pop();

        if (!yes[u]) done[u] = 1;
        if (done[u]) continue;
        done[u] = 1;
        vpii v = factor(u-1);
        for (i = 0; i < v.size(); i++) num[v[i].first] = max(num[v[i].first],v[i].second),Q.push(v[i].first);
    }
    for (i = 0; i < n; i++) {
        if (!done[p[i]]) num[p[i]] = max(num[p[i]],1);
    }
    LLI ans = 1;
    for (i = 2; i <= 2000000; i++) {
        if (num[i] > 0) {
            for (j = 0; j < num[i]; j++) ans *= i,ans %= MOD;
        }
    }
    printf("%I64d\n",ans);

    return 0;
}

#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef pair<int,int> Pii;
const int N = 2000020,mo=1e9+7;
int n,a[N],prime[N],len,mrk[N],b[N];
void getp(int n){
	rep(i,2,n){
		if(!mrk[i])prime[++len]=i;
		rep(j,1,len){
			if(i*prime[j]>n)break;
			mrk[i*prime[j]]=prime[j];if(i%prime[j]==0)break;
		}
	}
}
vector<Pii>solve(int x){
	vector<Pii>res;
	while(mrk[x]){
		int c=0,v=mrk[x];while(x%v==0)x/=v,c++;res.push_back(Pii(v,c));
	}
	if(x>1)res.push_back(Pii(x,1));
	return res;
}
int main(){
	getp(2000000);scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);bool ok=0;
	rep(i,1,n)
	if(!b[a[i]])b[a[i]]=1;
	else{
		bool gg=0;
		vector<Pii>f=solve(a[i]-1);per(i,SZ(f)-1,0)
			if(f[i].second>b[f[i].first])b[f[i].first]=f[i].second,gg=1;
		ok|=!gg;
	}
	/*rep(i,1,n){
		vector<Pii>f=solve(a[i]);bool bo=1;
		per(i,SZ(f)-1,0)bo&=(f[i].second==b[f[i].first].first&&b[f[i].first].second>=2);
		ok|=bo;
	}*/
	int res=1;rep(i,1,2000000)per(j,b[i],1)res=1LL*res*i%mo;if(ok)res=(res+1)%mo;
	cout<<res;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
const int M = 2e6 + 5;

const int mod = 1e9 + 7;

typedef pair <int, int> pii;

vector <pii> Div[M];
int n, pr[M], cnt, A[N], S[M], K[M];
bitset <M> isp;

namespace {
  int add(int x) {return (x >= mod) ? x - mod : x;}
  int sub(int x) {return (x < 0) ? x + mod : x;}
  void Add(int &x, int y) {x = add(x + y);}
  void Sub(int &x, int y) {x = sub(x - y);}
  int Pow(int x, int y) {
    int res = 1;
    for(; y; y >>= 1, x = 1LL * x * x % mod) {
      if(y & 1) {
	res = 1LL * res * x % mod;
      }
    }
    return res;
  }
}

vector <int> Chos;

void prework(int n) {
  for(int i = 2; i <= n; ++ i) isp[i] = 1;
  for(int i = 1; i <= n; ++ i) {
    if(isp[i]) pr[++ cnt] = i;
    for(int j = 1; j <= cnt && pr[j] * i <= n; ++ j) {
      isp[pr[j] * i] = 0;
      if(i % pr[j] == 0) break;
    }
  }
  for(int i = 1; i <= cnt; ++ i) {
    for(int j = pr[i]; j <= n; j += pr[i]) {
      int now = j, tot = 0;;
      while(now % pr[i] == 0) {
	now /= pr[i];
	++ tot;
      }
      Div[j].push_back(make_pair(pr[i], tot));
    }
  }
}

bool cmp(int x, int y) {
  return (x > y);
}

bool pd(int x) {
  bool ok = 1;
  for(int i = 0; i < (int) Div[x].size(); ++ i) {
    if(K[Div[x][i].first] - Div[x][i].second >= S[Div[x][i].first]) {
      ok = 1;
    }
    else ok = 0;
  }
  return ok;
}

main() {
  int ans = 1;
  prework(2e6);
  cin >> n;
  for(int i = 1; i <= n; ++ i) scanf("%d", &A[i]);
  sort(A + 1, A + n + 1, cmp);
  for(int i = 1; i <= n; ++ i) {
    if(!S[A[i]]) {
      ++ S[A[i]];
      ++ K[A[i]];
      Chos.push_back(A[i]);
    }
    else {
      for(int j = 0; j < (int)Div[A[i] - 1].size(); ++ j) {
	S[Div[A[i] - 1][j].first] = max(S[Div[A[i] - 1][j].first],
					Div[A[i] - 1][j].second)
	  , K[Div[A[i] - 1][j].first] += Div[A[i] - 1][j].second;
      }
      Chos.push_back(A[i] - 1);
    }
  }
  for(int i = 1; i < M; ++ i) {
    for(int j = 1; j <= K[i]; ++ j) ans = 1LL * ans * i % mod;
  }
  bool ok = 0;
  for(int i = 0; i < (int) Chos.size(); ++ i) {
    ok |= pd(Chos[i]);
  }
  cout << add(ans + ok) << endl;
}

#include <bits/stdc++.h>
#define FOR(i, a, b)	for (int (i)=(a); (i)<(b); (i)++)
#define PPC(x)			__builtin_popcountll((x))
#define ALL(x)			(x).begin(), (x).end()
#define pb				push_back
using namespace std;

const int maxN = 2000000, mod = 1000000007;

int apd[maxN], T[maxN], P[maxN];

inline void mult_mod(int& a, int b)
{   a = 1LL * a * b % mod;    }

int main()
{
	FOR(i, 1, maxN)
		apd[i] = i, P[i] = 1;
	for (int i=2; i*i<maxN; i++)
	{
		if (apd[i] != i)
			continue;
		for (int j=i*i; j<maxN; j+=i)
			apd[j] = i;
	}

	int n;
	scanf ("%d", &n);
	while (n--)
	{
		int a;
		scanf ("%d", &a);

		if (T[a] == 0)
		{
			T[a] = 1;
			P[a] = a;
			continue;
		}

		a--;
		while (a != 1)
		{
			int p = apd[a], c = 0;
			for (; a % p == 0; a /= p)
				c++;
			for (; T[p] < c; T[p]++)
				mult_mod(P[p], p);
		}
	}

	int res = 1;
	FOR(i, 1, maxN)
		mult_mod(res, P[i]);

	printf("%d\n", res);
	return 0;
}

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
const int maxn = 2e6 + 100;
int n, x, H[maxn], F[maxn], M[maxn], a[maxn];
const int MOD = 1e9 + 7;
vector<int> V[maxn];
set<int> S;
long long ans = 1;

void wtf(int x){
    for(auto o : V[x]){
        int temp = x, tot = 0;
        while(temp % o == 0) temp /= o, tot++;
        /*if(H[o] == 1 && S.find(o) != S.end()) {
            //cout<<o<<endl;
            wtf(o-1);
            S.erase(o);
            S.insert(o-1);
        }*/
        for(int i = H[o]+1; i <= tot; i++) (ans *= o) %= MOD;
        if(H[o] < tot){
            H[o] = max(H[o], tot);
            F[M[o]]--;
            M[o] = x; //****orzorzorz
            F[M[o]]++;
        }
    }
}

int main()
{
    for(int i = 2; i <= 2e6; i++){
        if(V[i].size() == 0)
            for(int j = 2; j*i <= 2e6; j++) V[i*j].push_back(i);
    }
    V[2].push_back(2);
    int f = 0, nt = 0;
    cin>>n;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a+1, a+1+n);
    for(int i = n; i >= 1; i--){
        x = a[i];
        H[x]++;
        if(H[x] == 1) {
            (ans *= x) %= MOD;
            M[x] = x;
            F[x]++;
            S.insert(x);
        }
        else if(H[x] >= 2) {
            x--;
            S.insert(x);
            long long rec = ans;
            wtf(x);
            if(rec == ans) f = 1;
        }
    }
    for(auto y : S) if(F[y] == 0) { cout<<ans+1<<endl; if(ans+1 == 327983056 && n == 148904) cout<<y<<" "<<ans+1<<endl; return 0; }
    cout<<ans + f<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
// ^ lol this makes everything look weird but I'll try it
tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;

// pairs
#define mp make_pair
#define f first
#define s second

// vectors
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const int IINF = 1e9;
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

// helper funcs
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

tcT> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; } // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

#define tcTU tcT, class U
tcTU> T fstTrue(T lo, T hi, U f) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
	lo --; assert(lo <= hi); // assuming f is decreasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo+1)/2;
		f(mid) ? lo = mid : hi = mid-1;
	}
	return lo;
}
tcT> void remDup(vector<T>& v) { // sort and remove duplicates
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
tcTU> void erase(T& t, const U& u) { // don't erase
	auto it = t.find(u); assert(it != end(t));
	t.erase(u); } // element that doesn't exist from (multi)set

// INPUT
#define tcTUU tcT, class ...U
tcT> void re(complex<T>& c);
tcTU> void re(pair<T,U>& p);
tcT> void re(vector<T>& v);
tcT, size_t SZ> void re(AR<T,SZ>& a);

tcT> void re(T& x) { cin >> x; }
void re(db& d) { str t; re(t); d = stod(t); }
void re(ld& d) { str t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }

tcT> void re(complex<T>& c) { T a,b; re(a,b); c = {a,b}; }
tcTU> void re(pair<T,U>& p) { re(p.f,p.s); }
tcT> void re(vector<T>& x) { trav(a,x) re(a); }
tcT, size_t SZ> void re(AR<T,SZ>& x) { trav(a,x) re(a); }

// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(bool b) {
	#ifdef LOCAL
		return b ? "true" : "false";
	#else
		return ts((int)b);
	#endif
}
tcT> str ts(complex<T> c) {
	stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) {
	str res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
	str res = ""; F0R(i,SZ) res += char('0'+b[i]);
	return res; }
tcTU> str ts(pair<T,U> p);
tcT> str ts(T v) { // containers with begin(), end()
	#ifdef LOCAL
		bool fst = 1; str res = "{";
		for (const auto& x: v) {
			if (!fst) res += ", ";
			fst = 0; res += ts(x);
		}
		res += "}"; return res;
	#else
		bool fst = 1; str res = "";
		for (const auto& x: v) {
			if (!fst) res += " ";
			fst = 0; res += ts(x);
		}
		return res;

	#endif
}
tcTU> str ts(pair<T,U> p) {
	#ifdef LOCAL
		return "("+ts(p.f)+", "+ts(p.s)+")";
	#else
		return ts(p.f)+" "+ts(p.s);
	#endif
}

// OUTPUT
tcT> void pr(T x) { cout << ts(x); }
tcTUU> void pr(const T& t, const U&... u) {
	pr(t); pr(u...); }
void ps() { pr("\n"); } // print w/ spaces
tcTUU> void ps(const T& t, const U&... u) {
	pr(t); if (sizeof...(u)) pr(" "); ps(u...); }

// DEBUG
void DBG() { cerr << "]" << endl; }
tcTUU> void DBG(const T& t, const U&... u) {
	cerr << ts(t); if (sizeof...(u)) cerr << ", ";
	DBG(u...); }
#ifdef LOCAL // compile with -DLOCAL, chk -> fake assert
	#define dbg(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
	#define chk(...) if (!(__VA_ARGS__)) cerr << "Line(" << __LINE__ << ") -> function(" \
		 << __FUNCTION__  << ") -> CHK FAILED: (" << #__VA_ARGS__ << ")" << "\n", exit(0);
#else
	#define dbg(...) 0
	#define chk(...) 0
#endif

// FILE I/O
void setIn(str s) { freopen(s.c_str(),"r",stdin); }
void setOut(str s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { cin.tie(0)->sync_with_stdio(0); }
void setIO(str s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit);
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template<int SZ> struct Sieve {
	vi pr;
	int sp[SZ]; // smallest prime that divides
	Sieve() { // above is faster
		memset(sp,0,sizeof sp);
		FOR(i,2,SZ) {
			if (sp[i] == 0) sp[i] = i, pr.pb(i);
			trav(p,pr) {
				if (p > sp[i] || i*p >= SZ) break;
				sp[i*p] = p;
			}
		}
	}
};
Sieve<2000010> S;

int main(){
	setIO();
	int n;
	cin >> n;
	vector<bool> asp(n);
	map<int, pi> m;
	vi p(n);
	sort(all(p), [](const int& a, const int& b){return a > b;});
	F0R(a, n){
		cin >> p[a];
		if(m[p[a]] == mp(0, 0))
			m[p[a]] = {1, 1}, asp[a] = true;
		else{
		int q = p[a] - 1;
		map<int, int> M;
		while(q != 1){
			M[S.sp[q]]++;
			q /= S.sp[q];
		}
		trav(b, M){
			auto temp = m[b.f];
			if(temp.f == b.s)
				m[b.f] = {temp.f, temp.s + 1};
			else if(temp.f < b.s)
				m[b.f] = {b.s, 1};
		}}
	}
	bool add = false;
	F0R(a, n){
		if(asp[a]){
			if(m[p[a]].f > 1 || m[p[a]].s > 1)
				add = true;
		}
		else{
			bool good = true;
			int q = p[a] - 1;
			map<int, int> M;
			while(q != 1){
				M[S.sp[q]]++;
				q /= S.sp[q];
			}
			trav(b, M){
				auto temp = m[b.f];
				if(!(temp.f > b.s || temp.s > 1))
					good = false;
			}
			if(good)
				add = true;
		}
	}
	ll lcm = 1;
	trav(a, m)
		lcm = (lcm * (ll)pow(a.f, a.s.f)) % MOD;
	cout << (lcm + add) % MOD << endl;
	// you should actually read the stuff at the bottom
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int cys=1000000007;
int n,tot;
ll a[200005],p[2000005],prm[10005];
bool fl[10005];

ll qpow(ll x,ll p){
	ll ret=1;
	for(;p;p>>=1,x=x*x%cys) if(p&1) ret=ret*x%cys;
	return ret;
}

void getprime(int N){
	fl[1]=1;
	for(int i=2;i<=N;i++){
		if(!fl[i]) prm[++tot]=i;
		for(int j=1;j<=tot&&i*prm[j]<=N;j++){
			fl[i*prm[j]]=1;
			if(i%prm[j]==0) break;
		}
	}
}

int main(){
	getprime(10000);
	n=readint();
	for(int i=1;i<=n;i++) a[i]=readint();
	sort(a+1,a+n+1); reverse(a+1,a+n+1);
	ll ans=1,now=0;
	for(int i=1;i<=n;i++){
		if(!p[a[i]]) p[a[i]]=1;
		else{
			int tmp=a[i]-1,ff=0;
			for(int j=1;j<=tot&&prm[j]<=sqrt(tmp);j++){
				if(tmp%prm[j]==0){
					ll cnt=0;
					while(tmp%prm[j]==0) cnt++,tmp/=prm[j];
					if(chkmax(p[prm[j]],cnt)) ff=1;
				}
			}
			if(tmp>1&&chkmax(p[tmp],1ll)) ff=1;
			if(!ff) now=1;
		}
	}
	for(int i=1;i<=2000000;i++) ans=ans*qpow(i,p[i])%cys;
	printf("%lld\n",(ans+now)%cys);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const int MAXN = 2000005;
const ll MOD = 1000000007;
int P[200005];
int pfac[MAXN], has[MAXN];
int main() {
	for (int i = 2; i < MAXN; ++i) pfac[i] = i;
	for (int i = 2; i < MAXN; ++i)
		if (pfac[i] == i) {
			for (int j = i + i; j < MAXN; j += i)
				pfac[j] = i;
		}
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", &P[i]);
	sort(P, P + n);
	ll ans = 1;
	for (int i = n - 1; i >= 0; --i) {
		if (has[P[i]]) {
			int x = P[i] - 1;
			while (x > 1) {
				int p = pfac[x];
				int cnt = 0;
				while (x % p == 0) {
					x /= p;
					++cnt;
				}
				while (has[p] < cnt) {
					++has[p];
					ans = ans * p % MOD;
				}
			}
		} else {
			has[P[i]] = 1;
			ans = ans * P[i] % MOD;
		}
	}
	printf("%lld\n", ans);
}

#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
int p[200009];
int P[2000009];
int f[2000009];
int F[2000009];
vector<int> V[2000009];
long long sc = 0;
void fa(int x){
    int s = 1;
    while(x > 1){
            int z = P[x];
            int k = 0;
            while(x % z == 0){
                x /= z;
                k++;
            }
            if(F[z] < k) F[z] = k, s= 0;
            V[z].push_back(k);
        }
    if(s) sc = 1;
}
void Fa(int x){
    int s = 1;
    while(x > 1){
            int z = P[x];
            int k = 0;
            while(x % z == 0){
                x /= z;
                k++;
            }
            if(V[z].size() == 1 || k > V[z][V[z].size()-2]) s = 0;
        }
    if(s) sc = 1;
}
main(){
    int n;
    cin >> n;
    for(int i = 2; i <= 2e6; i++){
        if(P[i] == 0){
            for(int j = i; j <= 2e6; j+=i)
                P[j] = i;
        }
    }
    for(int i = 0; i < n; i++){
        cin >>p[i];
        f[p[i]]++;
    }

    long long ans = 1;
    vector<int> t;

    for(int i = 2e6; i >= 1; i--){
        if(f[i] == 0) continue;
        if(f[i] >= 3) sc = 1;
        if(f[i] == 2){
            t.push_back(i);
            t.push_back(i-1);
            fa(i);
            fa(i-1);
            continue;
        }
        if(F[i]) fa(i-1),t.push_back(i-1);
        else fa(i),t.push_back(i);
    }
    for(int i = 0; i < t.size(); i++){
        Fa(t[i]);
    }
  //  cout<<sc<<endl;
    for(int i = 0; i <= 2e6; i++)
        sort(V[i].begin(),V[i].end());
    for(int i = 0; i <= 2e6; i++){
        for(int j = 0; j < F[i]; j++)
            ans = ans * (long long)i % mod;
    }
    if(sc) ans = (ans + 1) % mod;
    cout << ans << endl;

}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const ll p=1000000007;
const int N=2000010;
int pri[N],cnt,b[N];
int c[N];
int s[N];
int a[N];
void init()
{
	int maxn=2000000;
	for(int i=2;i<=maxn;i++)
	{
		if(!b[i])
		{
			pri[++cnt]=i;
			c[i]=i;
		}
		for(int j=1;j<=cnt&&i*pri[j]<=maxn;j++)
		{
			b[i*pri[j]]=1;
			c[i*pri[j]]=pri[j];
			if(i%pri[j]==0)
				break;
		}
	}
}
pii d[N];
pii s1[N],s2[N];
int n,t;
int bb[N];
int main()
{
	open("d");
	scanf("%d",&n);
	s[2]=1;
	int flag=0;
	init();
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(s[a[i]]==0)
		{
			s[a[i]]++;
			bb[i]=2;
			if(pii(a[i],i)>s1[a[i]])
			{
				s2[a[i]]=s1[a[i]];
				s1[a[i]]=pii(a[i],i);
			}
			else
				s2[a[i]]=max(s2[a[i]],pii(a[i],i));
		}
		else if(s[a[i]]==1)
		{
			s[a[i]]++;
			t=0;
			for(int j=a[i]-1;j!=1;j/=c[j])
				if(!t||d[t].first!=c[j])
					d[++t]=pii(c[j],c[j]);
				else
					d[t].second*=c[j];
			for(int j=1;j<=t;j++)
			{
				int v=d[j].first;
				d[j].first=d[j].second;
				d[j].second=i;
				if(d[j]>s1[v])
				{
					s2[v]=s1[v];
					s1[v]=d[j];
				}
				else
					s2[v]=max(s2[v],d[j]);
			}
			bb[i]=1;
		}
		else
			flag=1;
	}
	for(int i=1;i<=n&&!flag;i++)
		if(bb[i]==2)
		{
			if(s1[a[i]].second==i)
			{
				if(s2[a[i]].first==s1[a[i]].first)
				{
					flag=1;
					break;
				}
			}
			else
			{
				flag=1;
				break;
			}
		}
		else if(bb[i]==1)
		{
			t=0;
			for(int j=a[i]-1;j!=1;j/=c[j])
				if(!t||d[t].first!=c[j])
					d[++t]=pii(c[j],c[j]);
				else
					d[t].second*=c[j];
			int ff=1;
			for(int j=1;j<=t;j++)
			{
				int v=d[j].first;
				d[j].first=d[j].second;
				d[j].second=i;
				if(s1[v].second==i)
				{
					if(s2[v].first==s1[v].first)
						;
					else
						ff=0;
				}
			}
			if(ff)
			{
				flag=1;
				break;
			}
		}
	ll ans=1;
	for(int i=1;i<=2000000;i++)
		if(s1[i].first)
			ans=ans*s1[i].first%p;
	if(flag)
		ans++;
	printf("%I64d\n",ans);
	return 0;
}

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,p[SZ],mr[2000555];
bool np[2000555];
#define S 6000000
int fy[2000555];
int ny[S],yy[S],an;
const int MOD=1e9+7;
map<int,int> sb;
bool go(int g)
{
	int su=0;
	for(int t=fy[g];t;t=ny[t])
	{
		int y=0;
		while(g%yy[t]==0)
			++y,g/=yy[t];
		if(mr[yy[t]]>=y)
			continue;
		su=1; mr[yy[t]]=y;
	}
	return su;
}
ll zy[SZ]; int zn=0;
int main()
{
	for(int i=2;i<=2000000;++i) if(!np[i])
		for(int j=i;j<=2000000;j+=i)
			++an,yy[an]=i,ny[an]=fy[j],
			fy[j]=an,np[j]=1;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",p+i),++sb[-p[i]];
	int aa=0;
	for(auto g:sb)
	{
		if(g.se<2) continue;
		int w=-g.fi;
		if(!go(w)) aa=1;
		else zy[++zn]=w;
		for(int j=1;j<g.se;++j)
			if(!go(w-1)) aa=1;
			else zy[++zn]=w-1;
	}
	for(auto g:sb)
	{
		if(g.se!=1) continue;
		int w=-g.fi;
		if(go(w)) zy[++zn]=w;
		else if(go(w-1)) zy[++zn]=w-1;
		else aa=1;
	}
	memset(mr,0,sizeof mr);
	sort(zy+1,zy+1+zn);
	reverse(zy+1,zy+1+zn);
	for(int i=1;i<=zn;++i)
		if(!go(zy[i])) aa=1;
	ll ans=1;
	for(int i=1;i<=2000000;++i)
		while(mr[i]--) ans=ans*i%MOD;
	ans+=aa;
	ans=(ans%MOD+MOD)%MOD;
	cout<<ans<<"\n";
}

//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
bool tmp[2000111];
bool np[2000111];
int cnt[2000111];
vector<pair<int,int> > pfac[2000111];
int main()
{

	geti(n);
	vector<int> v;
	for(int i=1;i<=n;i++)
	{
		int x;
		geti(x);
		v.PB(x);
		tmp[x-1]=1;
	}
	for(int i=2;i<=2000000;i++)
	{
		if(np[i])continue;
		for(int j=i+i;j<=2000000;j+=i)
		{
			np[j]=1;
			if(tmp[j])
			{
				int c=0,t=j;
				while(t%i==0)
				{
					t/=i;
					c++;
				}
				pfac[j].PB(MP(i,c));
			}
		}
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	bool add1=0;
	for(int i=0;i<v.size();i++)
	{
		int x=v[i];
		if(cnt[x]==0)
		{
			cnt[x]=1;
		}
		else
		{
			bool ok=0;
			for(int j=0;j<pfac[x-1].size();j++)
			{
				int pr=pfac[x-1][j].FF,k=pfac[x-1][j].SS;
				if(cnt[pr]<k)
				{
					cnt[pr]=k;
					ok=1;
				}
			}
			if(!ok)add1=1;
		}
	}
	ll ans=1;
	for(int i=2;i<=2000000;i++)
	{
		if(cnt[i])ans=ans*qpow(i,cnt[i])%mod;
	}
	cout<<(ans+add1)%mod<<endl;
	return 0;
}

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
const int maxn = 2e6 + 100;
int n, x, H[maxn], F[maxn], M[maxn], a[maxn];
const int MOD = 1e9 + 7;
vector<int> V[maxn];
set<int> S;
long long ans = 1;

void wtf(int x){
    for(auto o : V[x]){
        int temp = x, tot = 0;
        while(temp % o == 0) temp /= o, tot++;
        /*if(H[o] == 1 && S.find(o) != S.end()) {
            //cout<<o<<endl;
            wtf(o-1);
            S.erase(o);
            S.insert(o-1);
        }*/
        for(int i = H[o]+1; i <= tot; i++) (ans *= o) %= MOD;
        if(H[o] <= tot){
            H[o] = max(H[o], tot);
            F[M[o]]--;
            M[o] = max(M[o], x);
            F[M[o]]++;
        }
    }
}

int main()
{
    for(int i = 2; i <= 2e6; i++){
        if(V[i].size() == 0)
            for(int j = 2; j*i <= 2e6; j++) V[i*j].push_back(i);
    }
    V[2].push_back(2);
    int f = 0, nt = 0;
    cin>>n;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a+1, a+1+n);
    for(int i = n; i >= 1; i--){
        x = a[i];
        H[x]++;
        if(H[x] == 1) {
            (ans *= x) %= MOD;
            M[x] = x;
            F[x]++;
            S.insert(x);
        }
        else if(H[x] >= 2) {
            x--;
            S.insert(x);
            long long rec = ans;
            wtf(x);
            if(rec == ans) f = 1;
        }
    }
    for(auto y : S) if(F[y] == 0) { cout<<ans+1<<endl; return 0; }
    cout<<ans + f<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

const size_t max_string_length = 100000;
template<class T> struct is_cstr: std::false_type {}; template<int N> struct is_cstr<char[N]> : std::true_type {};
template<typename T> constexpr string formcomm(const T& a) {if constexpr (is_same_v<T, int> || is_same_v<T, size_t>) return "%d"; else if constexpr (is_same_v<T, long long int>) return "%lld"; else if constexpr (is_same_v<T, short int>) return "%hd"; else if constexpr (is_same_v<T, unsigned int>) return "%u"; else if constexpr (is_same_v<T, unsigned long long int>) return "%llu"; else if constexpr (is_same_v<T, unsigned short int>) return "%hu"; else if constexpr (is_same_v<T, char>) return "%c"; else {printf("Type %s non prévu\n", typeid(a).name()); terminate();}}
template<typename T> constexpr string formout(const T& a) {if constexpr (is_same_v<T, float>) return "%.16f"; else if constexpr (is_same_v<T, double>) return "%.16lf"; else if constexpr (is_same_v<T, long double>) return "%.16Lf"; else if constexpr (is_same_v<T, string>) return "%s"; else if constexpr (is_cstr<T>::value) return "%s"; else return formcomm(a);}
template<typename T> const T& addout(const T& a) {return a;} const char* addout(const string& a) {return a.c_str();}
template<typename... Ts> void out(Ts&&... ts) {printf((formout(ts)+...).c_str(), addout(ts)...);}
template<typename It> void outs(It a, It b, string mid = " ", string fin = "\n") {if (a != b) {out(*a); ++a; for (; a != b; ++a) out (mid, *a);} out(fin);}
template<typename T> void outs(const T& l, string mid = " ", string fin = "\n") {outs(l.begin(), l.end(), mid, fin);}
template<typename T> constexpr string formin(const T& a) {if constexpr (is_same_v<T, float>) return "%f"; else if constexpr (is_same_v<T, double>) return "%lf"; else if constexpr (is_same_v<T, long double>) return "%Lf"; else if constexpr (is_same_v<T, string>) return "%s"; else if constexpr (is_cstr<T>::value) return "%s"; else return formcomm(a);}
template<typename T> constexpr int nstring(const T& a) {if constexpr (is_same_v<T, string>) return 1; else return 0;}
template<typename T> T* addin(T& a, char*& buf, string**& as) {return &a;} char* addin(string& a, char*& buf, string**& as) {char* ob = buf;buf+=max_string_length+1;*as = &a;++as;return ob;}
template<typename... Ts> void in(Ts&&... ts) {int ns=(nstring(ts)+...);string* as[max(ns,1)];char buf[1+(max_string_length+1)*ns];char* b=buf;string** c=as;
 scanf((formin(ts)+...).c_str(), addin(ts, b, c)...); while (c > as) {--c; b-=max_string_length+1; **c = string(b);}}
template<typename It> void ins(It a, It b) {for (; a != b; ++a) in (*a);} template<typename T> void ins(T& l) {ins(l.begin(), l.end());}
void inl(char* s) {scanf("%[^\n]", s);} void inl(string& s) {char buf[max_string_length+1]; inl(buf); s = string(buf);}

template<class T> T gcduv(const T&a, const T&b, T& u, T& v) {
 if (b == 0) {u = 1; v = 0; return a;} else
 {T g = gcduv(b, a%b, v, u); v -= u*(a/b); T q = u/b; u -= q*b; v += q*a; if (u < 0) {u += b; v -= a;} return g;}}
template<ll N> class mod {ll n; public:
 mod() {} mod(const ll& a): n(a) {n %= N; if (n < 0) n += N;} mod(const int& a): n(ll(a)) {n %= N; if (n < 0) n += N;}
 mod(const mod& a): n(a.n) {} int val() const {return int(n);} mod& operator= (const mod& a) {n = a.n; return *this;}
 bool iseq(const mod & a) const {return n == a.n;} mod inv() const {mod u; ll v; ll g = gcduv(n, N, u.n, v); assert(g == 1); return u;}
 mod operator-() const {mod u(-n); return u;}
 mod& operator+= (const mod& a) {n += a.n; n %= N; return *this;} mod& operator-= (const mod& a) {return *this += -a;}
 mod& operator*= (const mod& a) {n *= a.n; n %= N; return *this;} mod& operator/= (const mod& a) {return *this *= a.inv();}
 mod& operator++ () {++n; n %= N; return *this;} mod operator++ (int) {mod t = *this; ++*this; return t;}
 mod& operator-- () {n += N-1; n %= N; return *this;} mod operator-- (int) {mod t = *this; --*this; return t;}};
template<ll N> mod<N> operator+(const mod<N>& a, const mod<N>& b) {mod<N> r(a); r += b; return r;}
template<ll N> mod<N> operator-(const mod<N>& a, const mod<N>& b) {mod<N> r(a); r -= b; return r;}
template<ll N> mod<N> operator*(const mod<N>& a, const mod<N>& b) {mod<N> r(a); r *= b; return r;}
template<ll N> mod<N> operator/(const mod<N>& a, const mod<N>& b) {mod<N> r(a); r /= b; return r;}
template<ll N> bool operator==(const mod<N>& a, const mod<N>& b) {return a.iseq(b);}
template<ll N> bool operator!=(const mod<N>& a, const mod<N>& b) {return !(a == b);}
template<ll N, typename T> mod<N> operator+(const mod<N>& a, const T& b) {mod<N> r(a); r += mod<N>(b); return r;}
template<ll N, typename T> mod<N> operator-(const mod<N>& a, const T& b) {mod<N> r(a); r -= mod<N>(b); return r;}
template<ll N, typename T> mod<N> operator*(const mod<N>& a, const T& b) {mod<N> r(a); r *= mod<N>(b); return r;}
template<ll N, typename T> mod<N> operator/(const mod<N>& a, const T& b) {mod<N> r(a); r /= mod<N>(b); return r;}
template<ll N, typename T> bool operator==(const mod<N>& a, const T& b) {return a.iseq(mod<N>(b));}
template<ll N, typename T> bool operator!=(const mod<N>& a, const T& b) {return !(a == b);}
template<ll N, typename T> mod<N> operator+(const T& a, const mod<N>& b) {mod<N> r(a); r += b; return r;}
template<ll N, typename T> mod<N> operator-(const T& a, const mod<N>& b) {mod<N> r(a); r -= b; return r;}
template<ll N, typename T> mod<N> operator*(const T& a, const mod<N>& b) {mod<N> r(a); r *= b; return r;}
template<ll N, typename T> mod<N> operator/(const T& a, const mod<N>& b) {mod<N> r(a); r /= b; return r;}
template<ll N, typename T> bool operator==(const T& a, const mod<N>& b) {return b.iseq(mod<N>(a));}
template<ll N, typename T> bool operator!=(const T& a, const mod<N>& b) {return !(a == b);}

using imod = mod<1000000007>;

int main()
{
 int n;
 in(n);
 vector<int> ps(2000000, 0);
 imod res = 1;
 for (int i = 0; i < n; ++i)
 {
  int p;
  in(p);
  if (ps[p] == 0) res *= imod(p);
  else if (ps[p] == 1) res *= imod(p-1);

  ++ps[p];
 }
 out(res.val(), "\n");

 return 0;
}

#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef pair<int,int> Pii;
const int N = 2000020,mo=1e9+7;
int n,a[N],prime[N],len,mrk[N],b[N];
void getp(int n){
	rep(i,2,n){
		if(!mrk[i])prime[++len]=i;
		rep(j,1,len){
			if(i*prime[j]>n)break;
			mrk[i*prime[j]]=prime[j];if(i%prime[j]==0)break;
		}
	}
}
vector<Pii>solve(int x){
	vector<Pii>res;
	while(mrk[x]){
		int c=0,v=mrk[x];while(x%v==0)x/=v,c++;res.push_back(Pii(v,c));
	}
	if(x>1)res.push_back(Pii(x,1));
	return res;
}
int main(){
	getp(2000000);scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);bool ok=0;
	per(i,n,1)
	if(!b[a[i]])b[a[i]]=1;
	else{
		bool gg=0;
		vector<Pii>f=solve(a[i]-1);per(i,SZ(f)-1,0)
			if(f[i].second>b[f[i].first])b[f[i].first]=f[i].second,gg=1;
		ok|=!gg;
	}
	/*rep(i,1,n){
		vector<Pii>f=solve(a[i]);bool bo=1;
		per(i,SZ(f)-1,0)bo&=(f[i].second==b[f[i].first].first&&b[f[i].first].second>=2);
		ok|=bo;
	}*/
	int res=1;rep(i,1,2000000)per(j,b[i],1)res=1LL*res*i%mo;if(ok)res=(res+1)%mo;
	cout<<res;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define MOD 1000000007LL
#define MOD1 1000000009LL
#define INF 1000000000000000018LL
#define F first
#define S second
#define ll long long
#define eps 1e-9

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b)
{
	if(a == 0LL)
		return b;
	if(b == 0LL)
		return a;
	return gcd(b, a%b);
}

const int N = 200005;
const int M = 2000006;
int smpf[M];
int cnt[M];
int how[M];
int P[N];
bool mark[N];

void pre()
{
	for(int i = 1; i<M; i++)
		smpf[i] = i;
	for(int i = 2; i<M; i++)
		if(smpf[i] == i)
			for(int j = i+i; j<M; j+=i)
				if(smpf[j] == j)
					smpf[j] = i;
	return;
}

bool benefit(int x)
{
	if(x == 1)
		return false;

	vector<pii> v;
	v.clear();
	int cnt1, num;
	while(x != 1)
	{
		num = smpf[x];
		cnt1 = 0;
		while(smpf[x] == num)
		{
			cnt1++;
			x = x/num;
		}
		v.pb(mp(num, cnt1));
	}

	bool flag = false;
	for(int i = 0; i<v.size(); i++)
		flag = flag|(v[i].S > cnt[v[i].F]);

	if(flag)
	{
		for(int i = 0; i<v.size(); i++)
		{
			if(v[i].S > cnt[v[i].F])
			{
				how[v[i].F] = 1;
				cnt[v[i].F] = v[i].S;
			}
			else if(v[i].S == cnt[v[i].F])
				how[v[i].F]++;
		}
	}

	return flag;

}

bool check(int x)
{
	if(x == 1)
		return false;

	vector<pii> v;
	v.clear();
	int cnt1, num;
	while(x != 1)
	{
		num = smpf[x];
		cnt1 = 0;
		while(smpf[x] == num)
		{
			cnt1++;
			x = x/num;
		}
		v.pb(mp(num, cnt1));
	}

	bool flag = true;
	for(int i = 0; i<v.size(); i++)
	{
		if(cnt[v[i].F] == v[i].S && how[v[i].F] == 1)
		{
			flag = false;
			break;
		}
	}
	return flag;
}

void solve()
{
	pre();

	int n;
	bool flag = false;
	cin >> n;
	for(int i = 1; i<=n; i++)
	{
		cin >> P[i];
		if(benefit(P[i]))
			continue;
		else if(benefit(P[i]-1))
		{
			mark[i] = true;
			continue;
		}
		else
			flag = true;
	}
	if(!flag)
	{
		for(int i = 1; i<=n; i++)
			if(mark[i] && check(P[i]-1))
			{
				flag = true;
				break;
			}
	}
	ll ans = 1LL;
	for(int i = 1; i<M; i++)
	{
		while(cnt[i] > 0)
		{
			ans = (ans*((ll)i))%MOD;
			cnt[i]--;
		}
	}

	if(flag)
		ans++;

	ans = ans%MOD;
	cout << ans << "\n";

	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	// freopen("in.in", "r", stdin);
	// freopen("out.out", "w", stdout);

	clock_t clk = clock();

	int t = 1;
	// cin >> t;
	for(int tests = 1; tests <= t; tests++)
	{
		// cout << "Case #" << tests << ": ";
		solve();
	}

	clk = clock() - clk;
	cerr << "Time Elapsed: " << fixed << setprecision(10) << ((long double)clk)/CLOCKS_PER_SEC << "\n";

	return 0;
}

	//CuongTV

#include <bits/stdc++.h>

#define ll long long
#define ii pair<int, int>
#define pb push_back
#define vi vector<int>
#define F first
#define S second
#define MAXN 2000000
using namespace std;

template <typename T> ostream& operator<<(ostream &out, vector<T> v){for(T t: v) out << t << ' '; return out;}
template <typename T> ostream& operator<<(ostream &out, set<T> v){for(T t: v) out << t << ' '; return out;}
template <typename T> ostream& operator<<(ostream &out, pair<T, T> v){out << v.F << ' ' << v.S; return out;}
//Declare global variables

ll powMod(ll a, ll x, ll mod){
	if(x == 0) return 1;
	if(x & 1) return a * powMod(a, x - 1, mod) % mod;
	ll temp = powMod(a, x >> 1, mod);
	return temp * temp % mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<int> p(n);
    map<int, int> mm, res;
    ll mod = 1e9 + 7;

    for(int i = 0; i < n; ++i){
    	cin >> p[i];
    	mm[p[i]]++;
    	if(res[p[i]] == 0) res[p[i]]++;
    }
    vector<vector<int> > div(MAXN + 1);

    for(int i = 2; i <= MAXN; ++i){
    	if(div[i].empty()){
    		for(int j = i; j <= MAXN; j += i){
    			div[j].pb(i);
    		}
    	}
    }

    for(auto t: mm){
    	if(t.S >= 2){
    		int num = t.F - 1;
    		for(int i : div[t.F - 1]){
    			int pow = 0;
    			while(num % i == 0){
    				num /= i;
    				pow++;
    			}
    			res[i] = max(res[i], pow);
    		}
    	}
    }

    ll r = 1;
    for(auto t: res){
    	r = r * powMod(t.F, t.S, mod) % mod;
    }
    cout << r;
    return 0;
}

#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int cys=1000000007;
int n,tot;
ll a[200005],p[2000005],prm[10005];
bool fl[10005];

ll qpow(ll x,ll p){
	ll ret=1;
	for(;p;p>>=1,x=x*x%cys) if(p&1) ret=ret*x%cys;
	return ret;
}

void getprime(int N){
	fl[1]=1;
	for(int i=2;i<=N;i++){
		if(!fl[i]) prm[++tot]=i;
		for(int j=1;j<=tot&&i*prm[j]<=N;j++){
			fl[i*prm[j]]=1;
			if(i%prm[j]==0) break;
		}
	}
}

int main(){
	getprime(10000);
	n=readint();
	for(int i=1;i<=n;i++) a[i]=readint();
	sort(a+1,a+n+1); reverse(a+1,a+n+1);
	ll ans=1;
	for(int i=1;i<=n;i++){
		if(!p[a[i]]) p[a[i]]=1;
		else{
			int tmp=a[i]-1,ff=0;
			for(int j=1;j<=tot&&prm[j]<=sqrt(tmp);j++){
				if(tmp%prm[j]==0){
					ll cnt=0;
					while(tmp%prm[j]==0) cnt++,tmp/=prm[j];
					if(chkmax(p[prm[j]],cnt)) ff=1;
				}
			}
			if(tmp>1&&chkmax(p[tmp],1ll)) ff=1;
			if(!ff) ans=2;
		}
	}
	for(int i=1;i<=2000000;i++) ans=ans*qpow(i,p[i])%cys;
	printf("%lld\n",ans);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define vll vector <long long>
#define pii pair < int, int >
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second

const int inf = (int)1e9 + 100;
const int mod = (int)1e9 + 7;
const double eps = 1e-9;
const int MaxN = 2e5 + 1;
const double pi = acos(-1.0);
int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a,res%=mod;
		a *= a,a%=mod;
		n >>= 1;
	}
	return res;
}
ll n,m,k,x,y,d,maxx,q,cnt,ans;
int p[MaxN], lp[2000010];
pair<int,int> a[2000010];
int main(){
   // ios_base::sync_with_stdio(0), cin.tie(0);
    n=2000000;
    vector<int> pr;
    for(int i=2;i<=n;i++){
        if(lp[i]==0){
            lp[i]=i;
            pr.pb(i);
        }
        for(int j=0;j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=n;j++)
            lp[i*pr[j]] = pr[j];
    }
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>x;
        if(!a[x].f)a[x]=mp(1,1),p[i]=x;
        else {
            x--,p[i]=x,cnt=1;
            while(lp[x]){
                if(lp[x]==lp[x/lp[x]])cnt++;
                else {
                    if(cnt>a[lp[x]].f)a[lp[x]]=mp(cnt,1);
                    else if(cnt==a[lp[x]].f)a[lp[x]].s++;
                    cnt=1;
                }
                x/=lp[x];
            }
        }
    }
    ans=1;
    for(ll i=2;i<=2e6;i++)
        ans=(ans*binpow(i,a[i].f))%mod;
    for(ll i=0;i<n;i++){
        x=p[i];
        bool ok=true;
        cnt=1;
        while(lp[x]){
                if(lp[x]==lp[x/lp[x]])cnt++;
                else {
                    if(cnt==a[lp[x]].f&&a[lp[x]].s==1){
                        ok=false;
                        break;
                    }
                    cnt=1;
                }
                x/=lp[x];
        }
        if(ok)return cout<<(ans+1)%mod, 0;
    }
    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
template<typename T> ostream& operator<<(ostream& os, vector<T> a){os<<"( ";for(T &x:a)os<<x<<" ";os<<")\n";return os;}
template<typename T> ostream& operator<<(ostream& os, set<T> a){os<<"( ";for(T x:a)os<<x<<" ";os<<")\n";return os;}
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2> a){os<<"("<<a.first<<" "<<a.second<<") ";return os;}
template<typename T> ostream& operator<<(ostream& os, complex<T> a){os<<"(r="<<a.real()<<" i="<<a.imag()<<") ";return os;}
typedef long long ll;
typedef double dd;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;
#define all(a) a.begin(),a.end()
#ifdef OFFLINE
#define DEBUG 1
#else
#define DEBUG 0
#endif
#define debug(a) if(DEBUG)cout<<#a<<" = "<<a<<endl
#define x first
#define y second
const int base=1000000007;
ll power(ll a,ll n,ll mod=base){ll r=1;while(n){if (n&1) r=r*a%mod;a=a*a%mod;n>>=1;}return r;}
//===========================Head=========================//
const int nmax=2000011;
int f[nmax], cnt[nmax];

int main(int argc,char** argv){
    for(int i=2;i<nmax;++i) if (f[i]==0){
        for (int j=i;j<nmax;j+=i) f[j]=i;
    }
    int n;
    scanf("%d",&n);
    vi p(n);
    for (auto &i:p) scanf("%d",&i);
    sort(all(p));
    reverse(all(p));
    int flag=0;
    for (auto x:p){
        if (cnt[x]) --x;
        int ok=0;
        while(x>1){
            int u=f[x], k=0;
            while(x%u==0){
                ++k;
                x/=u;
            }
            if (k>cnt[u]){
                cnt[u] = k;
                ok=1;
            }
        }
        if (!ok) flag=1;
    }
    ll ans=1;
    for (int i=2;i<nmax;++i){
        while(cnt[i]--){
            ans = ans*i%base;
        }
    }
    ans += flag;
    cout<<ans;
}

#include <bits/stdc++.h>
using namespace std;
#define forsn(i,s,n) for(int i = int(s);i<int(n);i++)
#define dforsn(i,s,n) for(int i = int(n)-1;i>=int(s);i--)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) dforsn(i,0,n)
#define DBG(x) do{cout<<#x<<" = "<<x<<endl;}while(false)
typedef long long intl;
typedef long long ll;
#define MAXN   2000001
int spf[MAXN];
void sieve() {
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        spf[i] = i;
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++) {
        if (spf[i] == i) {
            for (int j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<pair<int,int>> getFactorization(int x) {
    vector<pair<int,int>> ret;
	int last=1;
	int count=1;
    while (x != 1) {
    	if(last!=spf[x]){
    		if(last!=1){
    			ret.push_back({last,count});
			}
			count=1;
			last=spf[x];
		}
		else{
			count++;
		}
        x = x / spf[x];
    }
    if(last!=1){
       ret.push_back({last,count});
	}
    return ret;
}
intl MOD=1e9+7;
intl fst(intl x,intl e){
	intl ans=1;
	while(e>0){
		if(e%2==1){
			ans*=x;
			ans=ans%MOD;
		}
		x*=x;
		x=x%MOD;
		e/=2;
	}
	return ans;
}
int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);
    sieve();
   	int n;
   	cin>>n;
   	map <int,int> factors;
   	map<int,int> many;
   	vector <int> visited(MAXN,0);
   	intl sum=0;
   	vector <int> orig;
   	for(int i=0;i<n;i++){
   		int a;
		cin>>a;
		if(visited[a]){
			vector<pair<int,int> >  v=getFactorization(a-1);
			for(auto x:v){
				if(!factors.count(x.first)){
					factors[x.first]=x.second;
					many[x.first]=0;
				}
				if(factors[x.first]<x.second){
					factors[x.first]=x.second;
					many[x.first]=1;
				}
				else if(factors[x.first]==x.second){
					many[x.first]++;
				}
			}
		}
		else{
			vector<pair<int,int> > v=getFactorization(a);
			for(auto x:v){
				if(!factors.count(x.first)){
					factors[x.first]=x.second;
					many[x.first]=0;
				}
				if(factors[x.first]<x.second){
					factors[x.first]=x.second;
					many[x.first]=1;
				}
				else if(factors[x.first]==x.second){
					many[x.first]++;
				}
			}
		}
		orig.push_back(a);
		visited[a]++;
	}
	vector <int> visited1(MAXN,0);
	for(int i=0;i<n;i++){
		int a=orig[i];
		bool nopuedo=false;
		if(visited1[a]){
			vector<pair<int,int> >  v=getFactorization(a-1);
			for(auto x:v){
				//cout<<factors[x.first]<<" "<<x.first<<" "<<x.second<<" "<<many[x.first]<<endl;
				if(factors[x.first]==x.second && many[x.first]==1){
					nopuedo=true;
				}
			}
		}
		else{
			vector<pair<int,int> > v=getFactorization(a);
			for(auto x:v){
				if(factors[x.first]==x.second && many[x.first]==1){
					nopuedo=true;
				}
			}
		}
		visited1[a]++;
		if(!nopuedo){
			sum=1;
		}
	}
	intl ans=1;
	for(auto x:factors){
		ans*=fst(intl(x.first),intl(x.second));
		ans=ans%MOD;
	}
	cout<<(ans+sum)%MOD<<endl;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 200005, M = 2000005, SM = 2000, P = 1000000007;
int p[N], cnt[M], cp[N], fl[M];

int ip[M], pr[M], np;

int main() {
    int n;
    scanf("%d", &n);
    int flag = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", p + i);
        cnt[p[i]]++;
        if (cnt[p[i]] > 1) {
            p[i]--;
        }
    }
    for (int i = 2; i < M; ++i) {
        if (!ip[i]) {
            pr[np++] = i;
            for (int j = i + i; j < M; j += i) {
                ip[j] = 1;
            }
        }
    }
    ll ans = 1;
    for (int i = 0; i < 500; ++i) {
        int mx = 0;
        for (int j = 0; j < n; ++j) {
            cp[j] = 0;
            while (p[j] % pr[i] == 0) {
                cp[j]++;
                p[j] /= pr[i];
            }
            mx = max(mx, cp[j]);
        }
        int mc = 0, id = 0;
        for (int j = 0; j < n; ++j) {
            if (cp[j] == mx) {
                mc++, id = j;
                if (mc >= 2) break;
            }
        }
        if (mc == 1) {
            fl[id] = 1;
        }
        for (int j = 0; j < mx; ++j) {
            ans = ans * pr[i] % P;
        }
    }
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; ++i) {
        if (p[i] <= pr[499]) continue;
        cnt[p[i]]++;
        if (cnt[p[i]] == 1) {
            ans = ans * p[i] % P;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (p[i] <= pr[499]) continue;
        if (cnt[p[i]] == 1) {
            fl[i] = 1;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (!fl[i]) flag = 1;
    }
    ans += flag;
    printf("%I64d\n", ans % P);
}

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e6 + 10;
int a[N];
int d[N];
int prime[N];
int key[N];
int cnt[N];
int cnt2[N];
int k = 0;
inline void init()
{
	for (int i = 2; i < N; i++)
	{
		if (!a[i])
			prime[++k] = i, d[i] = i;
		for (int j = 1; j <= k && (LL)i*prime[j] < N; j++)
		{
			d[i*prime[j]] = prime[j];
			a[i*prime[j]] = 1;
			if (i%prime[j] == 0)
				break;
		}
	}
	for (int i = 2; i < N; i++)
	{
		if (i / d[i] % d[i] == 0) key[i] = d[i] * key[i / d[i]];
		else key[i] = d[i];
	}
}

void check(int x)
{
	while (x > 1)
	{
		cnt2[key[x]]++;
		x /= key[x];
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	init();
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	int ok = 0;
	for (int i = 1; i <= k; i++)
	{
		int p = prime[i];
		if (cnt[p] > 2) ok = 1;
		else if (p == 2 && cnt[p] > 1) ok = 1;
		if (cnt[p])
		{
			check(p);
			cnt[p]--;
		}
		if (cnt[p]) check(p - 1);
	}
	for (int i = N - 1; i > 1; i--)
	{
		if (cnt2[i] <= 0)
		{
			continue;
		}
		int x = i;
		int sum = -cnt2[i];
		while (x > 1)
		{
			x /= d[x];
			cnt2[x] = -2;
		}
	}
	for (int i = 1; i <= k && !ok; i++)
	{
		int p = prime[i];
		if (cnt[p] == 0) continue;
		int cnt = 0;
		int tot = 0;
		int x = p - 1;
		while (x > 1)
		{
			tot++;
			if (cnt2[key[x]] != 1) cnt++;
			x /= key[x];
		}
		if (cnt == tot) ok = 1;
	}
	LL ans = 1;
	for (int i = N - 1; i > 1; i--)
	{
		if (cnt2[i] <= 0) continue;
		ans = ans * i%INF;
	}
	if (ok) ans++;
	if (ans >= INF) ans -= INF;
	printf("%lld\n", ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define FF first
#define SS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 2000007;
const int MOD = SC ( int, 1e9 + 7 );

int n;
int tc[MAXN], c[MAXN], cp[MAXN], mx[MAXN], un[MAXN];
bool isp[MAXN];
AR(PII) frac[MAXN];

void init ();
void input ();
void work ();

int main()
{
	init();
	input();
	work();
}

void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );

	INIT ( isp, true );
	isp[0] = isp[1] = false;
	lp ( i, 2, MAXN ){
		if ( isp[i] ){
			frac[i].PB ( MP ( i, 1 ) );
			for ( int j = i << 1; j < MAXN; j += i ){
				isp[j] = false;
				int t = j, nc = 0;
				while ( t % i == 0 ) t /= i, ++nc;
				frac[j].PB ( MP ( i, nc ) );
			}
		}
	}
}

void input ()
{
	// input method

	scanf ( "%d", &n );
	int x;
	lpi ( i, 1, n ){
		scanf ( "%d", &x );
		++c[x];
	}
}

void work ()
{
	// main work

	memcpy ( tc, c, sizeof ( c ) );
	INIT ( c, 0 );
	lpd ( i, MAXN-1, 0 ){
		c[i] += qmin ( tc[i], 1 ), c[i-1] += qmax ( tc[i]-1, 0 );
	}

	lp ( i, 1, MAXN ){
		if ( c[i] ){
			for ( auto j : frac[i] ){
				if ( mx[j.FF] < j.SS ) mx[j.FF] = j.SS, cp[j.FF] = c[i];
				else if ( mx[j.FF] == j.SS ) cp[j.FF] += c[i];
			}
		}
	}

	int ans = 1;
	lp ( i, 1, MAXN ){
		lp ( j, 0, mx[i] ) ans = SC ( LL, ans ) * i % MOD;
	}

	bool flag = false, cur;
	lp ( i, 1, MAXN ){
		if ( c[i] ){
			cur = true;
			for ( auto x : frac[i] ){
				if ( cp[x.FF] == 1 && mx[x.FF] == x.SS ){
					cur = false;
					break;
				}
			}
			if ( cur ){
				flag = true;
				break;
			}
		}
		if ( c[i] >= 2 || ( c[i] && un[i] == i ) ){
			flag = true;
			break;
		}
	}
	if ( flag ) ( ans += 1 ) %= MOD;

	cout << ans << endl;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

const ll mod=1e9+7;
ll n,a[200010],prime[2000010],cnt[2000010],pre,ans=1;
bool unpri[2000010];

inline bool cmp1(int x,int y){return x>y;}

inline void Eular(int N){
	for(int i=2;i<=N;i++){
		if(!unpri[i]) prime[++prime[0]]=i;
		for(int j=1;j<=prime[0]&&i*prime[j]<=N;j++){
			unpri[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}return;
}

inline bool work(ll x){
	int tmp,fail=1;
	for(int i=1;i<=prime[0];i++){
		if(prime[i]*prime[i]>x) break;
		tmp=0;
		while(x%prime[i]==0) tmp++,x/=prime[i];
		if(tmp>cnt[prime[i]]) fail=0,cnt[prime[i]]=tmp;
	}
	if(!cnt[x]) fail=0,cnt[x]=1;
	return fail;
}

inline ll qpow(ll x,ll k){
	ll res=1;
	while(k){
		if(k&1) res=res*x%mod;
		x=x*x%mod;k>>=1;
	}return res;
}

int main(){
	n=read();Eular(2000000);cnt[1]=1;
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1,cmp1);
	for(int i=1;i<=n;i++){
		if(!cnt[a[i]]) cnt[a[i]]++;
		else if(work(a[i]-1)) pre=1;
	}
	for(int i=2;i<=2000000;i++) ans=ans*qpow(i,cnt[i])%mod;
	cout<<(ans+pre)%mod<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int p[2000001];
int num[2000001];
const int mod = 1e9 + 7;
int s[2000001];
void pre()
{
    for(int i = 2;i <= 2000000;i++){
        if(!p[i]){
            p[i] = i;
            for(int j = i*2;j <= 2000000;j += i){
                if(!p[j]) p[j] = i;
            }
        }
    }
    return;
}
void sp(int x)
{
    while(x > 1){
        int j = p[x];int ned = 0;
        while(p[x] == j && x > 1){
            ned++;x /= p[x];
        }
        s[j] = max(s[j] , ned);
    }
    return;
}
int power(int a,int b)
{
    int ans = 1;
    while(b){
        if(b & 1) ans = (1LL * ans * a) % mod;
        a = (1LL * a *a) %mod;b >>= 1;
    }
    return ans;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int n;scanf("%d",&n);
    pre();
    for(int i = 1;i <= n;i++){
        int x;
        scanf("%d",&x);num[x]++;
    }
    for(int i = 1;i <= 2000000;i++){
        if(num[i] >= 1){
            s[i] = max(s[i] , 1);
            if(num[i] >= 2) sp(i-1);
        }
    }
    int ans = 1;
    for(int i = 1;i <= 2000000;i++){
        if(s[i]) ans = (1LL * ans * power(i , s[i])) % mod;
    }
    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
const int M = 2e6 + 5;

const int mod = 1e9 + 7;

typedef pair <int, int> pii;

vector <pii> Div[M];
int n, pr[M], cnt, A[N], S[M], K[M];
bitset <M> isp;

namespace {
  int add(int x) {return (x >= mod) ? x - mod : x;}
  int sub(int x) {return (x < 0) ? x + mod : x;}
  void Add(int &x, int y) {x = add(x + y);}
  void Sub(int &x, int y) {x = sub(x - y);}
  int Pow(int x, int y) {
    int res = 1;
    for(; y; y >>= 1, x = 1LL * x * x % mod) {
      if(y & 1) {
	res = 1LL * res * x % mod;
      }
    }
    return res;
  }
}

vector <int> Chos;

void prework(int n) {
  for(int i = 2; i <= n; ++ i) isp[i] = 1;
  for(int i = 1; i <= n; ++ i) {
    if(isp[i]) pr[++ cnt] = i;
    for(int j = 1; j <= cnt && pr[j] * i <= n; ++ j) {
      isp[pr[j] * i] = 0;
      if(i % pr[j] == 0) break;
    }
  }
  for(int i = 1; i <= cnt; ++ i) {
    for(int j = pr[i]; j <= n; j += pr[i]) {
      int now = j, tot = 0;;
      while(now % pr[i] == 0) {
	now /= pr[i];
	++ tot;
      }
      Div[j].push_back(make_pair(pr[i], tot));
    }
  }
}

bool cmp(int x, int y) {
  return (x > y);
}

bool pd(int x) {
  bool ok = 1;
  for(int i = 0; i < (int) Div[x].size(); ++ i) {
    if(K[Div[x][i].first] - Div[x][i].second >= S[Div[x][i].first]) {
      ok = 1;
    }
    else ok = 0;
  }
  return ok;
}

main() {
  int ans = 1;
  prework(2e6);
  cin >> n;
  for(int i = 1; i <= n; ++ i) scanf("%d", &A[i]);
  sort(A + 1, A + n + 1, cmp);
  for(int i = 1; i <= n; ++ i) {
    if(!S[A[i]]) {
      ++ S[A[i]];
      ++ K[A[i]];
      Chos.push_back(A[i]);
    }
    else {
      for(int j = 0; j < (int)Div[A[i] - 1].size(); ++ j) {
	S[Div[A[i] - 1][j].first] = max(S[Div[A[i] - 1][j].first],
					Div[A[i] - 1][j].second)
	  , K[Div[A[i] - 1][j].first] += Div[A[i] - 1][j].second;
      }
      Chos.push_back(A[i] - 1);
    }
  }
  for(int i = 1; i < M; ++ i) {
    for(int j = 1; j <= S[i]; ++ j) ans = 1LL * ans * i % mod;
  }
  bool ok = 0;
  for(int i = 0; i < (int) Chos.size(); ++ i) {
    ok |= pd(Chos[i]);
  }
  cout << add(ans + ok) << endl;
}

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	int mx = *max_element(p.begin(), p.end());
	vector<bool> isprime(mx + 1);
	for (int i = 2; i <= mx; ++i) isprime[i] = true;
	for (int i = 2; i * i <= mx; ++i) {
		if (!isprime[i]) continue;
		for (int j = i * i; j <= mx; j += i) {
			isprime[j] = false;
		}
	}
	vector<int> primes;
	vector<int> pid(mx + 1, -1);
	for (int i = 2; i <= mx; ++i) {
		if (isprime[i]) {
			pid[i] = primes.size();
			primes.push_back(i);
		}
	}
	vector<int> cnt(primes.size()), top1(primes.size()), top2(primes.size());
	for (int i = 0; i < n; ++i) {
		++cnt[pid[p[i]]];
	}
	for (int i = 0; i < primes.size(); ++i) {
		if (cnt[i] >= 1) top1[i] = 1;
		if (cnt[i] <= 1) continue;
		int x = primes[i] - 1;
		for (int j = 0; primes[j] * primes[j] <= x; ++j) {
			int divcnt = 0;
			while (x % primes[j] == 0) {
				x /= primes[j];
				++divcnt;
			}
			if (divcnt > top1[j]) {
				top2[j] = top1[j];
				top1[j] = divcnt;
			}
			else if (divcnt > top2[j]) {
				top2[j] = divcnt;
			}
		}
		if (x > 1) {
			if (top1[pid[x]] == 0) {
				top1[pid[x]] = 1;
			}
			else if (top2[pid[x]] == 0) {
				top2[pid[x]] = 1;
			}
		}
	}
	bool flag = false;
	for (int i = 0; i < primes.size(); ++i) {
		if (cnt[i] <= 1) continue;
		if (cnt[i] >= 3) {
			flag = true;
			continue;
		}
		int x = primes[i] - 1;
		bool decrease = false;
		for (int j = 0; primes[j] * primes[j] <= x; ++j) {
			int divcnt = 0;
			while (x % primes[j] == 0) {
				x /= primes[j];
				++divcnt;
			}
			if (divcnt == top1[j] && top1[j] > top2[j]) {
				decrease = true;
			}
		}
		if (x > 1) {
			if (top1[pid[x]] == 1 && top1[pid[x]] > top2[pid[x]]) {
				decrease = true;
			}
		}
		if (!decrease) flag = true;
	}
	for (int i = 0; i < primes.size(); ++i) {
		if (cnt[i] >= 1 && (top1[i] != 1 || top1[i] == top2[i])) {
			flag = true;
		}
	}
	int ans = 1;
	for (int i = 0; i < primes.size(); ++i) {
		for (int j = 0; j < top1[i]; ++j) {
			ans = (long long)(ans) * primes[i] % mod;
		}
	}
	if (flag) ans = (ans + 1) % mod;
	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N=2e6+10;
const int mod=1e9+7;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,pri[N],tt,minp[N],mx[N],op[N],cnt[N],p[N];
bool vis[N];

vector<pii> fac(int x) {
	vector<pii> ret;
	while(x>1) {
		int y=minp[x];ret.pb(mp(y,0));
		while(x%y==0) ++ret.back().se,x/=y;
	}
	return ret;
}

int main() {
	for(int i=2;i<N;i++)
		if(!vis[i]) {
			pri[++tt]=i;minp[i]=i;
			for(int j=i+i;j<N;j+=i) {
				vis[j]=1;
				if(!minp[j]) minp[j]=i;
			}
		}
	cin>>n;
	for(int i=1;i<=n;i++) {
		p[i]=gi();
		if(!mx[p[i]]) mx[p[i]]=cnt[p[i]]=1,op[i]=1;
		else {
			auto vec=fac(p[i]-1);
			for(auto x:vec) {
				if(mx[x.fi]<x.se) mx[x.fi]=x.se,cnt[x.fi]=1;
				else if(mx[x.fi]==x.se) ++cnt[x.fi];
			}
		}
	}
	int ans=1;bool fl=0;
	for(int i=1;i<N;i++) {
		for(int j=1;j<=mx[i];j++) ans=1ll*ans*i%mod;
	}
	for(int i=1;i<=n&&!fl;i++)
		if(op[i]) {
			fl|=(mx[p[i]]>1||cnt[p[i]]>1);
		}
		else {
			auto vec=fac(p[i]-1);
			bool all=1;
			for(auto x:vec) all&=(mx[x.fi]>x.se||cnt[x.fi]>1);
			fl|=all;
		}
	if(fl) ans=(ans+1)%mod;
	cout<<ans;
	return 0;
}

#ifndef LOCAL
#define NDEBUG
#endif
#include<cassert>
#include<iostream>
#include<algorithm>
#include<vector>

int const MOD=1000000007;
struct modular {
	int val;
	explicit constexpr operator int() const { return val; }
	constexpr modular():val(){}
#if MODULAR_LESS_EFFICIENT_BUT_EASIER_TO_CODE
	constexpr modular(int64_t v):val(int(v%MOD)){
		if(val<0)val+=MOD;
	}
#else
	constexpr modular(int v):val(v){
		assert(0<=v and v<MOD);
	}
#endif

#define COMPAREOP(OP) bool constexpr operator OP(modular b) const { return val OP b.val; }
	COMPAREOP(==) COMPAREOP(!=) COMPAREOP(<) COMPAREOP(>) COMPAREOP(<=) COMPAREOP(>=)
#undef COMPAREOP

	modular operator-() const { return modular(val ? MOD-val : 0); }
	modular constexpr& operator+=(modular m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	modular constexpr& operator-=(modular m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	modular constexpr& operator*=(modular m) { val = int((int64_t)val*m.val%MOD); return *this; }
	modular constexpr pow(int p) const {
		modular a=*this;
		modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	modular constexpr inv() const {
		int a=val,b=MOD, ax=1,bx=0;
		while(b){
			int q=a/b, t=a%b;
			a=b; b=t;
			t=ax-bx*q; ax=bx; bx=t;
		}
		assert(a==1);
		if(ax<0)ax+=MOD;
		return ax;
	}
	modular constexpr& operator/=(modular m) { return (*this) *= m.inv(); }

#define ARITHBINARYOP(OP) friend modular constexpr operator OP(modular a, modular b) { return a OP##= b; }
	ARITHBINARYOP(+) ARITHBINARYOP(-) ARITHBINARYOP(*) ARITHBINARYOP(/)
#undef ARITHBINARYOP
};

int main(){
	std::ios::sync_with_stdio(0);std::cin.tie(0);
	int n;std::cin>>n;
	std::vector<int> p(n);
	int maxp=0;
	for(int& pi:p){
		std::cin>>pi;
		maxp=std::max(maxp,pi);
	}

	std::vector<int> cnt(maxp+1);
	for(int pi:p)++cnt[pi];

	std::vector<int> minf(std::max(10,maxp+1));
	for(int p=2;p<(int)minf.size();++p)if(minf[p]==0){
		minf[p]=p;
		for(int64_t j=p*(int64_t)p;j<(int64_t)minf.size();j+=p)
			if(minf[j]==0)
				minf[j]=p;
	}

	bool add=std::any_of(begin(cnt),end(cnt),[](int x){return x>=3;});
	// let some ai=0, then out will be incremented by 1 (can be done at most once)
	// it should always be done when there's some prime appears more than 2 times

	std::vector<int> out_exp(maxp+1);

	for(int p=2;p<(int)cnt.size();++p)if(cnt[p]>=1){
		out_exp[p]=std::max(out_exp[p],1);
	}

	std::vector<std::pair<int,int>> factors;
	for(int p=2;p<(int)cnt.size();++p)if(cnt[p]>=2){
		factors.clear();
		int x=p-1;
		while(x>1){
			int q=minf[x];
			int exp=0;
			do{ ++exp;x/=q; } while(x%q==0);
			factors.push_back({q,exp});
		}

		if(std::all_of(begin(factors),end(factors),[&out_exp](auto q_exp){
					auto [q,exp]=q_exp;
					return out_exp[q]>=exp;
					})){
			// useless second occurence
			add=true;
			continue;
		}

		for(auto [p,exp]:factors){
			out_exp[p]=std::max(out_exp[p],exp);
		}
	}

	modular out=1;
	for(int p=2;p<(int)out_exp.size();++p)if(out_exp[p]){
		assert(minf[p]==p);
		out*=modular(p).pow(out_exp[p]);
	}

	if(add)out+=1;
	std::cout<<(int)out<<'\n';
}

#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
#define NN 2000010
int prime[NN];
int flag[NN];
int vst[NN];
int cnt[NN];
int p[NN];
int r[NN];
int s[NN];
int num[NN];
int np;
int pp[NN];
void prepare(){
	for(int i=2;i<NN;i++){
		if(!flag[i]){
			prime[np++]=i;
			flag[i]=i;
		}
		for(int j=0;j<np&&prime[j]*i<NN;j++){
			flag[i*prime[j]]=prime[j];
			if(flag[i]==prime[j]) break;
		}
	}
}
int power(int a,int b,int m,int ans=1){
	for(;b;b>>=1,a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;
	return ans;
}
bool cmp(int u,int v){
	return u>v;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	prepare();
	int n;
	scanf("%d",&n);
	int m=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		cnt[p[i]]++;
	}
  	sort(p+1,p+n+1,cmp);
  	n=unique(p+1,p+n+1)-p-1;
  	int Flag=0;
  	for(int i=1;i<=n;i++){
  		if(!Flag){
			if(cnt[p[i]]>2||(cnt[p[i]]==2&&vst[p[i]]==1)) Flag=1;
			else{
				if(cnt[p[i]]==1&&vst[p[i]]==1) pp[m++]=p[i];
				if(cnt[p[i]]==2&&vst[p[i]]==0) pp[m++]=p[i];
			}
		}
  		if(!vst[p[i]]) r[p[i]]++;
		if(cnt[p[i]]>1||vst[p[i]]){
			int st=p[i]-1;
			while(st>1){
				int q=flag[st];
				vst[q]=1;
				int t=0;
				while(st%q==0){
					t++;
					st/=q;
					if(r[q]<t) r[q]=t;
				}
			}
		}
	}
	if(!Flag){
		for(int i=0;i<m;i++){
			int st=pp[i]-1;
			while(st>1){
				int q=flag[st];
				int t=0;
				while(st%q==0){
					t++;
					st/=q;
				}
				if(s[q]<t){
					num[q]=1;
					s[q]=t;
				}
				else if(s[q]==t) num[q]++;
			}
		}
		int Vst=0;
		for(int i=0;i<m;i++){
			int st=pp[i]-1;
			while(st>1){
				int q=flag[st];
				int t=0;
				while(st%q==0){
					t++;
					st/=q;
				}
				if(t==s[q]&&num[q]==1) Vst=1;
			}
			if(!Vst){
				Flag=1;
				break;
			}
		}
	}
	int ans=1;
	for(int i=2;i<=p[1];i++) ans=(long long)ans*power(i,r[i],mod)%mod;
	ans+=Flag;
	printf("%d\n",ans);
    return 0;
}

//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
bool f[2000111],np[2000111];
int main()
{
	geti(n);
	vector<int> v;
	for(int i=1;i<=n;i++)
	{
		int x;
		geti(x);
		v.PB(x);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		int x=v[i];
		if(f[x])f[x-1]=1;
		else f[x]=1;
	}
	ll ans=1;
	for(int i=2;i<=2000000;i++)
	{
		if(np[i])continue;
		int mx=0;
		for(int j=i;j<=2000000;j+=i)
		{
			if(j>i)np[j]=1;
			if(f[j])
			{
				int c=0,t=j;
				while(t%i==0)
				{
					t/=i;
					c++;
				}
				mx=max(mx,c);
			}
		}
		while(mx--)
		{
			ans=ans*i%mod;
		}
	}
	cout<<ans<<endl;
	return 0;
}

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = 2e6+100;
const LL mod = 1e9+7;
int esp[MAXN];
int ppp[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    for (int p = 2; p < MAXN; p++) {
        if (ppp[p]) continue;
        ppp[p] = p;
        for (int i = 2*p; i < MAXN; i+=p) ppp[i] = p;
    }

    int N;
    cin >> N;
    vector<int> primes(N);
    for (int i = 0; i < N; i++) cin >> primes[i];
    sort(primes.begin(), primes.end());
    reverse(primes.begin(), primes.end());
    int add1 = 0;
    for (int p: primes) {
        if (esp[p]) {
            int x = p-1;
            bool improved = false;
            while (x != 1) {
                int e = 0;
                int q = ppp[x];
                while (x % q == 0) e++, x /= q;
                if (esp[q] < e) {
                    improved = true;
                    esp[q] = e;
                }
            }
            if (!improved) add1 = true;
        } else esp[p]++;
    }

    LL res = 1;
    for (int p = 2; p < MAXN; p++) {
        for (int e = 0; e < esp[p]; e++) res = (res * p)%mod;
    }
    cout << (res +add1)%mod<< "\n";
}

#include <bits/stdc++.h>

using namespace std;

const int N = 200010;
const int M = 2000010;
const int MOD = 1000000007;

int n;
int cnt[M];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int u;
		scanf("%d", &u);
		cnt[u]++;
	}
	int res = 1;
	int add = 0;
	for (int i = 1; i < M; i++) {
		if (cnt[i]) {
			if (cnt[i] == 1) {
				res = 1ll * res * i % MOD;
			} else {
				res = 1ll * res * i % MOD;
				if (i > 2) {
					res = 1ll * res * (i - 1) % MOD;
				} else {
					add = 1;
				}
				if (cnt[i] > 2) {
					add = 1;
				}
			}
		}
	}
	res = (res + add) % MOD;
	cout << res << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define MOD 1000000007LL
#define MOD1 1000000009LL
#define INF 1000000000000000018LL
#define F first
#define S second
#define ll long long
#define eps 1e-9

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b)
{
	if(a == 0LL)
		return b;
	if(b == 0LL)
		return a;
	return gcd(b, a%b);
}

const int M = 2000006;
int smpf[M];
int cnt[M];

void pre()
{
	for(int i = 1; i<M; i++)
		smpf[i] = i;
	for(int i = 2; i<M; i++)
		if(smpf[i] == i)
			for(int j = i+i; j<M; j+=i)
				if(smpf[j] == j)
					smpf[j] = i;
	return;
}

bool benefit(int x)
{
	if(x == 1)
		return false;

	vector<pii> v;
	v.clear();
	int cnt1, num;
	while(x != 1)
	{
		num = smpf[x];
		cnt1 = 0;
		while(smpf[x] == num)
		{
			cnt1++;
			x = x/num;
		}
		v.pb(mp(num, cnt1));
	}

	bool flag = false;
	for(int i = 0; i<v.size(); i++)
	{
		flag = flag|(v[i].S > cnt[v[i].F]);
		cnt[v[i].F] = max(cnt[v[i].F], v[i].S);
	}

	return flag;

}

void solve()
{
	pre();

	int n, P;
	bool flag = false;
	cin >> n;
	for(int i = 1; i<=n; i++)
	{
		cin >> P;
		if(benefit(P))
			continue;
		else if(benefit(P-1))
			continue;
		else
			flag = true;
	}
	ll ans = 1LL;
	for(int i = 1; i<M; i++)
		while(cnt[i] > 0)
		{
			ans = (ans*i)%MOD;
			cnt[i]--;
		}
	if(flag)
		ans++;
	ans = ans%MOD;
	cout << ans << "\n";

	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	// freopen("in.in", "r", stdin);
	// freopen("out.out", "w", stdout);

	clock_t clk = clock();

	int t = 1;
	// cin >> t;
	for(int tests = 1; tests <= t; tests++)
	{
		// cout << "Case #" << tests << ": ";
		solve();
	}

	clk = clock() - clk;
	cerr << "Time Elapsed: " << fixed << setprecision(10) << ((long double)clk)/CLOCKS_PER_SEC << "\n";

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 2e5 + 7;
const int M = 2e6 + 7;

int n, T[N], fa[M], is[N];
map < int, int > MP;

int main()
{
    _upgrade

    for(int i = 2; i * i < M; i++)
    {
        if(fa[i] != 0) continue;
        for(int j = i * i; j < M; j += i)
        {
            if(fa[j] == 0)
            {
                fa[j] = i;
            }
        }
    }
    for(int i = 2; i < M; i++)
    {
        if(fa[i] == 0)
        {
            fa[i] = i;
        }
    }

    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> T[i];
        int p = T[i];
        if(MP[p] == 0)
        {
            MP[p]++;
            is[i] = true;
        }
        else
        {
            p--;
            while(p > 1)
            {
                MP[fa[p]]++;
                p /= fa[p];
            }
        }
    }

    bool can = false;
    for(int i = 0; i < n; i++)
    {
        int p = T[i];
        if(is[i])
        {
            if(MP[p] > 1)
            {
                can = true;
            }
        }
        else
        {
            bool ok = true;
            p--;
            while(p > 1)
            {
                int cnt = 0, d = fa[p];
                while(p % d == 0)
                {
                    p /= d;
                    cnt++;
                }
                if(MP[d] == cnt)
                {
                    ok = false;
                }
            }
            if(ok)
            {
                can = true;
            }
        }
    }

    const int MOD = 1e9 + 7;

    LL ans = 1;
    for(auto p: MP)
    {
        ans = (ans * p.first) % MOD;
    }
    if(can)
    {
        ans = (ans + 1) % MOD;
    }
    cout << ans << "\n";

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int,int> pii;

const int N = 2000001;
const int Mod = 1e9 + 7;

void add_self(int& x, int y)
{
    if((x += y) >= Mod) x -= Mod;
}

void sub_self(int& x, int y)
{
    if((x -= y) < 0)    x += Mod;
}

int add(int x, int y)
{
    return add_self(x, y), x;
}

int sub(int x, int y)
{
    return sub_self(x, y), x;
}

int mul(int x, int y)
{
    return (ll) x * y % Mod;
}

int fp(int x, ll y)
{
    int Res = 1;
    for(; y > 0; y >>= 1, x = mul(x, x))
        if(y & 1)
            Res = mul(Res, x);
    return Res;
}

int Log(int x, int y)
{
    int Res = 0;
    while(x % y == 0)   x /= y, Res++;
    return Res;
}

int Cnt1[N];
int Cnt2[N];
vector <pii> P[N];

int main()
{
    for(int x = 2; x < N; x++)
        if(P[x].empty())
            for(int y = x; y < N; y += x)
                P[y].emplace_back(x, Log(y, x));

    int n;  cin >> n;

    vector <int> a(n);
    for(int& x : a) scanf("%d", &x);
    sort(a.begin(), a.end(), greater <int> ());

    for(int x : a)
    {
        if(!Cnt1[x])
        {
            Cnt1[x] = 1;
        }

        else
        {
            for(pii p : P[x - 1])
            {
                if(Cnt1[p.first] == p.second)   Cnt2[p.first]++;

                if(Cnt1[p.first] < p.second)
                {
                    Cnt2[p.first] = 1;
                    Cnt1[p.first] = p.second;
                }
            }
        }
    }

    int PlusOne = 0;

    for(int x : a)
    {
        int Min = 2;

        for(pii p : P[x - 1])
            if(p.second == Cnt1[p.first])
                Min = min(Min, Cnt2[p.first]);

        if(Min == 2)    PlusOne = 1;
    }

    int Ans = 1;
    for(int x = 1; x < N; x++)  Ans = mul(Ans, fp(x, Cnt1[x]));
    add_self(Ans, PlusOne);
    cout << Ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAXN = 2000005;
const lint mod = 1e9 + 7;

int n, a[MAXN];
int che[MAXN];
int cnt[MAXN];
int yielder[MAXN];

lint ipow(lint x, lint p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

vector<int> factor(int v){
	if(v == 1){
		return vector<int>();
	}
	vector<int> ans;
	while(v > 1){
		ans.push_back(che[v]);
		v /= che[v];
	}
	return ans;
}

int main(){
	scanf("%d",&n);
	for(int i=2; i<MAXN; i++){
		for(int j=i; j<MAXN; j+=i){
			if(!che[j]) che[j] = i;
		}
	}
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	sort(a, a+n);
	set<int> s;
	int useless = 0;
	queue<int> que;
	for(int i=0; i<n; ){
		int e = i;
		while(e < n && a[i] == a[e]) e++;
		if(e - i == 1) s.insert(a[i]);
		else{
			if(e - i >= 3) useless = 1;
			que.push(a[i] - 1);
			que.push(a[i]);
		}
		i = e;
	}
	vector<int> will_check;
	while(!que.empty()){
		auto x = que.front();
		will_check.push_back(x);
		que.pop();
		auto v = factor(x);
		for(int i=0; i<v.size(); ){
			int e = i;
			while(e < v.size() && v[i] == v[e]) e++;
			if(cnt[v[i]] < e - i){
				cnt[v[i]] = e - i;
			}
			if(cnt[v[i]] && s.find(v[i]) != s.end()){
				s.erase(v[i]);
				que.push(v[i] - 1);
			}
			i = e;
		}
	}
	for(auto &i : s){
		cnt[i] = 1;
	}
	lint ans = 1;
	for(int i=2; i<MAXN; i++){
		ans *= ipow(i, cnt[i]);
		ans %= mod;
	}
	if(!useless){
		for(int i=0; i<n; ){
			int e = i;
			while(e < n && a[e] == a[i]) e++;
			if(e - i == 2) a[i]--;
			else if(s.find(a[i]) == s.end()) a[i]--;
			i = e;
		}
		for(int i=0; i<n; i++){
			auto x = factor(a[i]);
			for(int j=0; j<x.size(); ){
				int e = j;
				while(e < x.size() && x[e] == x[j]) e++;
				if(cnt[x[j]] == e - j) yielder[x[j]]++;
				j = e;
			}
		}
		for(int i=0; i<n; i++){
			auto x = factor(a[i]);
			bool useful = 0;
			for(int j=0; j<x.size(); ){
				int e = j;
				while(e < x.size() && x[e] == x[j]) e++;
				if(cnt[x[j]] == e - j && yielder[x[j]] == 1) useful = 1;
				j = e;
			}
			if(!useful) useless++;
		}
	}
	ans += useless;
	ans %= mod;
	cout << ans << endl;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cassert>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
using namespace std;

#define P 1000000007

int n, p[2100000], ma[2100000], cnt_ma[2100000];
int mark[2100000];
bool used[2100000], solid[2100000];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &p[i]);
	}
	sort(p + 1, p + n + 1);
	for (int i = 1; i <= n; i++) {
		if (i == 1 || p[i] != p[i - 1]) {
			mark[p[i]]++;
		}else {
			mark[p[i] - 1]++;
		}
	}
	int ans = 1;
	for (int i = 2; i <= 2000000; i++) {
		if (!used[i]) {
			for (int j = 2 * i; j <= 2000000; j += i)
				used[j] = true;
		}
		ma[i] = 0;
		for (int j = i; j <= 2000000; j += i)
			if (mark[j]) {
				int cnt = 0;
				int copy = j;
				while (copy % i == 0) {
					copy /= i;
					cnt ++;
				}
				if (cnt > ma[i]) {
					ma[i] = cnt;
					cnt_ma[i] = 1;
				}else if (cnt == ma[i]) {
					cnt_ma[i] ++;
				}
			}
		for (int j = i; j <= 2000000; j += i)
			if (mark[j]) {
				int cnt = 0;
				int copy = j;
				while (copy % i == 0) {
					copy /= i;
					cnt ++;
				}
				if (cnt == ma[i] && cnt_ma[i] == 1) {
					solid[j] = true;
				}
			}

		for (int j = 1; j <= ma[i]; j++) {
			ans = 1LL * ans * i % P;
		}
	}
	for (int i = 1; i <= 2000000; i++)
		if ((mark[i] > 0 && !solid[i]) || mark[i] > 1) {
			ans++;
			break;
		}
	printf("%d\n", ans);
}

#include<bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;
const int MX = 2000010;
const int MN = 200010;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}

vector<int> pr;
int pchk[MX];

void sieve() {
    for(int i = 2; i < MX; i++) {
        if(!pchk[i]) {
            pr.push_back(i);
            pchk[i] = i;
        }
        for(int j = 0; j < pr.size() && i * pr[j] < MX; j++) {
            pchk[ i * pr[j] ] = pr[j];
            if(i % pr[j] == 0) break;
        }
    }
}

int N;
int cnt[MX], pcnt[MX];

int main() {
    sieve();

    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        int t; scanf("%d", &t);
        cnt[t]++;
    }

    for(int i = 0; i < pr.size(); i++) {
        if(!cnt[ pr[i] ]) continue;
        pcnt[ pr[i] ] = 1;
        if(cnt[ pr[i] ] > 1) {
            int t = pr[i] - 1;
            int p = -1;
            int c = 0;
            while(t != 1) {
                if(p != pchk[t]) {
                    if(p != -1) pcnt[p] = max(pcnt[p], c);
                    p = pchk[t];
                    c = 0;
                }
                c++;
                t /= pchk[t];
            }
        }
    }
    int ans = 1;
    for(int i = 0; i < pr.size(); i++) {
        ans = 1LL * ans * exp(pr[i], pcnt[ pr[i] ]) % mod;
    }
    printf("%d", ans);
}

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
// ^ lol this makes everything look weird but I'll try it
tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;

// pairs
#define mp make_pair
#define f first
#define s second

// vectors
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const int IINF = 1e9;
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

// helper funcs
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

tcT> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; } // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

#define tcTU tcT, class U
tcTU> T fstTrue(T lo, T hi, U f) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
	lo --; assert(lo <= hi); // assuming f is decreasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo+1)/2;
		f(mid) ? lo = mid : hi = mid-1;
	}
	return lo;
}
tcT> void remDup(vector<T>& v) { // sort and remove duplicates
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
tcTU> void erase(T& t, const U& u) { // don't erase
	auto it = t.find(u); assert(it != end(t));
	t.erase(u); } // element that doesn't exist from (multi)set

// INPUT
#define tcTUU tcT, class ...U
tcT> void re(complex<T>& c);
tcTU> void re(pair<T,U>& p);
tcT> void re(vector<T>& v);
tcT, size_t SZ> void re(AR<T,SZ>& a);

tcT> void re(T& x) { cin >> x; }
void re(db& d) { str t; re(t); d = stod(t); }
void re(ld& d) { str t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }

tcT> void re(complex<T>& c) { T a,b; re(a,b); c = {a,b}; }
tcTU> void re(pair<T,U>& p) { re(p.f,p.s); }
tcT> void re(vector<T>& x) { trav(a,x) re(a); }
tcT, size_t SZ> void re(AR<T,SZ>& x) { trav(a,x) re(a); }

// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(bool b) {
	#ifdef LOCAL
		return b ? "true" : "false";
	#else
		return ts((int)b);
	#endif
}
tcT> str ts(complex<T> c) {
	stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) {
	str res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
	str res = ""; F0R(i,SZ) res += char('0'+b[i]);
	return res; }
tcTU> str ts(pair<T,U> p);
tcT> str ts(T v) { // containers with begin(), end()
	#ifdef LOCAL
		bool fst = 1; str res = "{";
		for (const auto& x: v) {
			if (!fst) res += ", ";
			fst = 0; res += ts(x);
		}
		res += "}"; return res;
	#else
		bool fst = 1; str res = "";
		for (const auto& x: v) {
			if (!fst) res += " ";
			fst = 0; res += ts(x);
		}
		return res;

	#endif
}
tcTU> str ts(pair<T,U> p) {
	#ifdef LOCAL
		return "("+ts(p.f)+", "+ts(p.s)+")";
	#else
		return ts(p.f)+" "+ts(p.s);
	#endif
}

// OUTPUT
tcT> void pr(T x) { cout << ts(x); }
tcTUU> void pr(const T& t, const U&... u) {
	pr(t); pr(u...); }
void ps() { pr("\n"); } // print w/ spaces
tcTUU> void ps(const T& t, const U&... u) {
	pr(t); if (sizeof...(u)) pr(" "); ps(u...); }

// DEBUG
void DBG() { cerr << "]" << endl; }
tcTUU> void DBG(const T& t, const U&... u) {
	cerr << ts(t); if (sizeof...(u)) cerr << ", ";
	DBG(u...); }
#ifdef LOCAL // compile with -DLOCAL, chk -> fake assert
	#define dbg(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
	#define chk(...) if (!(__VA_ARGS__)) cerr << "Line(" << __LINE__ << ") -> function(" \
		 << __FUNCTION__  << ") -> CHK FAILED: (" << #__VA_ARGS__ << ")" << "\n", exit(0);
#else
	#define dbg(...) 0
	#define chk(...) 0
#endif

// FILE I/O
void setIn(str s) { freopen(s.c_str(),"r",stdin); }
void setOut(str s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { cin.tie(0)->sync_with_stdio(0); }
void setIO(str s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit);
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template<int SZ> struct Sieve {
	vi pr;
	int sp[SZ]; // smallest prime that divides
	Sieve() { // above is faster
		memset(sp,0,sizeof sp);
		FOR(i,2,SZ) {
			if (sp[i] == 0) sp[i] = i, pr.pb(i);
			trav(p,pr) {
				if (p > sp[i] || i*p >= SZ) break;
				sp[i*p] = p;
			}
		}
	}
};
Sieve<2000010> S;

int main(){
	setIO();
	int n;
	cin >> n;
	vector<bool> asp(n);
	map<int, pi> m;
	vi p(n);
	F0R(a, n){
		cin >> p[a];
		if(m[p[a]] == mp(0, 0))
			m[p[a]] = {1, 1}, asp[a] = true;
		else{
		int q = p[a] - 1;
		map<int, int> M;
		while(q != 1){
			M[S.sp[q]]++;
			q /= S.sp[q];
		}
		trav(b, M){
			auto temp = m[b.f];
			if(temp.f == b.s)
				m[b.f] = {temp.f, temp.s + 1};
			else if(temp.f < b.s)
				m[b.f] = {b.s, 1};
		}}
	}
	bool add = false;
	F0R(a, n){
		if(asp[a]){
			if(m[p[a]].f > 1 || m[p[a]].s > 1)
				add = true;
		}
		else{
			bool good = true;
			int q = p[a] - 1;
			map<int, int> M;
			while(q != 1){
				M[S.sp[q]]++;
				q /= S.sp[q];
			}
			trav(b, M){
				auto temp = m[b.f];
				if(!(temp.f > b.s || temp.s > 1))
					good = false;
			}
			if(good)
				add = true;
		}
	}
	ll lcm = 1;
	trav(a, m)
		lcm *= pow(a.f, a.s.f);
	cout << lcm + add << endl;
	// you should actually read the stuff at the bottom
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

#include <iostream>
#include <ios>
#include <cstdint>
#include <vector>
#include <algorithm>

using ul = std::uint32_t;
using ull = std::uint64_t;
using li = std::int32_t;
using ll = std::int64_t;
using vull = std::vector<ull>;
using vul = std::vector<ul>;

const ul base = 1e9 + 7;

vul datas(2e5);
ul n;
vul ans(2e6 + 1, 0);

ul times(ul a, ul b) {
    return ull(a) * b % base;
}

ul pow(ul a, ul b) {
    if (b) {
        ul temp = pow(a, b >> 1);
        return (b & 1) ? times(temp, times(temp, a)) : times(temp, temp);
    } else {
        return ul(1);
    }
}

int main()
{
    std::cin >> n;
    datas.resize(n);
    for (ul i = 0; i != n; ++i) {
        std::cin >> datas[i];
    }
    std::sort(datas.rbegin(), datas.rend());
    for (ul p : datas) {
        if (ans[p]) {
            --p;
        }
        for (ul i = 2; i * i <= p; ++i) {
            ul cnt = 0;
            while (!(p % i)) {
                p /= i;
                ++cnt;
            }
            ans[i] = std::max(ans[i], cnt);
        }
        if (p) {
            ans[p] = std::max(ans[p], ul(1));
        }
    }
    ul out = 1;
    for (ul i = 2; i != ans.size(); ++i) {
        out = times(out, pow(i, ans[i]));
    }
    std::cout << out << std::endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define vll vector <long long>
#define pii pair < int, int >
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second

const int inf = (int)1e9 + 100;
const int mod = (int)1e9 + 7;
const double eps = 1e-9;
const int MaxN = 2e5 + 1;
const double pi = acos(-1.0);
int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a,res%=mod;
		a *= a,a%=mod;
		n >>= 1;
	}
	return res;
}
ll n,m,k,x,y,d,maxx,q,cnt,ans;
int p[MaxN], lp[2000010];
pair<int,int> a[2000010];
int main(){
   // ios_base::sync_with_stdio(0), cin.tie(0);
    n=2000000;
    vector<int> pr;
    for(int i=2;i<=n;i++){
        if(lp[i]==0){
            lp[i]=i;
            pr.pb(i);
        }
        for(int j=0;j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=n;j++)
            lp[i*pr[j]] = pr[j];
    }
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>x;
        if(!a[x].f)a[x]=mp(1,1),p[i]=x;
        else {
            x--,p[i]=x,cnt=1;
            while(lp[x]){
                if(lp[x]==lp[x/lp[x]])cnt++;
                else {
                    if(cnt>a[lp[x]].f)a[lp[x]]=mp(cnt,1);
                    else if(cnt==a[lp[x]].f)a[lp[x]].s++;
                    cnt=1;
                }
                x/=lp[x];
            }
        }
    }
    ans=1;
    for(ll i=2;i<=2e6;i++)
        ans=(ans*binpow(i,a[i].f))%mod;
    for(ll i=0;i<n;i++){
        x=p[i];
        bool ok=true;
        cnt=1;
        while(lp[x]){
                if(lp[x]==lp[x/lp[x]])cnt++;
                else {
                    if(cnt==a[lp[x]].f&&a[lp[x]].s==1){
                        ok=false;
                        break;
                    }
                    cnt=1;
                }
                x/=lp[x];
        }
        if(ok)return cout<<(ans+1)%mod, 0;
    }
    cout<<ans;
}

/**
  * @file pc.cpp
  * @brief codeforces

  *

  * @author yao
  * @date 2018-09-23
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <map>
#define N 262144
#define M 2097152
#define MOD ((int)1e9+7)
#define NUM_PRIME 262144
#define MAX_PRIME 2097152
#define INF ((int)1e9)
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#endif //DBG

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int prime[NUM_PRIME],nprime;
int min_factor[MAX_PRIME];
void euler_siece()
{
    for(int i=2;i<MAX_PRIME;++i)
    {
        if(!min_factor[i]) prime[nprime++]=i, min_factor[i]=i;
        for(int j=0; i*prime[j] < MAX_PRIME; ++j)
        {
            min_factor[i*prime[j]] = prime[j];
            if(i%prime[j]==0) break;
        }
    }
    dbg_pri("poi euler_siece: max=%d num=%d n=%d\n",MAX_PRIME,NUM_PRIME,nprime);
}

int a[N];
int f[M];

int main()
{
    euler_siece();
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        scanf("%d",a+i);
    std::sort(a,a+n,std::greater<int>());
    for(int i=0;i<n;++i)
    {
        int k=a[i]-f[a[i]];
        while(k!=1) f[min_factor[k]] = 1, k/=min_factor[k];
    }
    int ans = 1;
    for(int i=0;i<M;++i)
        if(f[i]) ans = (lli)ans * i % MOD;
    printf("%d\n",ans);
    return 0;
}

#include <iostream>
#include <vector>
using namespace std;
const int maxn = 2e6 + 100;
int n, x, H[maxn];
const int MOD = 1e9 + 7;
vector<int> V[maxn];
int main()
{
    long long ans = 1;
    for(int i = 2; i <= 2e6; i++){
        if(V[i].size() == 0)
            for(int j = 2; j*i <= 2e6; j++) V[i*j].push_back(i);
    }
    V[2].push_back(2);
    int f = 0;
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>x;
        H[x]++;
        if(H[x] == 1) (ans *= x) %= MOD;
        else if(H[x] >= 2) {
            x--;
            long long rec = ans;
            for(auto o : V[x]){
                int temp = x, tot = 0;
                while(temp % o == 0) temp /= o, tot++;
                for(int i = H[o]+1; i <= tot; i++) (ans *= o) %= MOD;
                H[o] = max(H[o], tot);
            }
            if(rec == ans) f = 1;
        }
    }
    cout<<ans+f<<endl;
    return 0;
}

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	int mx = *max_element(p.begin(), p.end());
	vector<bool> isprime(mx + 1);
	for (int i = 2; i <= mx; ++i) isprime[i] = true;
	for (int i = 2; i * i <= mx; ++i) {
		if (!isprime[i]) continue;
		for (int j = i * i; j <= mx; j += i) {
			isprime[j] = false;
		}
	}
	vector<int> primes;
	vector<int> pid(mx + 1, -1);
	for (int i = 2; i <= mx; ++i) {
		if (isprime[i]) {
			pid[i] = primes.size();
			primes.push_back(i);
		}
	}
	vector<int> cnt(primes.size()), top1(primes.size()), top2(primes.size());
	for (int i = 0; i < n; ++i) {
		++cnt[pid[p[i]]];
	}
	for (int i = 0; i < primes.size(); ++i) {
		if (cnt[i] >= 1) top1[i] = 1;
		if (cnt[i] <= 1) continue;
		int x = primes[i] - 1;
		for (int j = 0; primes[j] * primes[j] < x; ++j) {
			int divcnt = 0;
			while (x % primes[j] == 0) {
				x /= primes[j];
				++divcnt;
			}
			if (divcnt > top1[j]) {
				top2[j] = top1[j];
				top1[j] = divcnt;
			}
			else if (divcnt > top2[j]) {
				top2[j] = divcnt;
			}
		}
		if (x > 1) {
			if (top1[pid[x]] == 0) {
				top1[pid[x]] = 1;
			}
			else if (top2[pid[x]] == 0) {
				top2[pid[x]] = 1;
			}
		}
	}
	bool flag = false;
	for (int i = 0; i < primes.size(); ++i) {
		if (cnt[i] <= 1) continue;
		int x = primes[i] - 1;
		bool decrease = false;
		for (int j = 0; primes[j] * primes[j] < x; ++j) {
			int divcnt = 0;
			while (x % primes[j] == 0) {
				x /= primes[j];
				++divcnt;
			}
			if (divcnt == top1[j] && top1[j] > top2[j]) {
				decrease = true;
			}
		}
		if (x > 1) {
			if (top1[pid[x]] == 1 && top1[pid[x]] > top2[pid[x]]) {
				decrease = true;
			}
		}
		if (!decrease) flag = true;
	}
	int ans = 1;
	for (int i = 0; i < primes.size(); ++i) {
		for (int j = 0; j < top1[i]; ++j) {
			ans = (long long)(ans) * primes[i] % mod;
		}
	}
	if (flag) ans = (ans + 1) % mod;
	cout << ans << endl;
	return 0;
}

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=2e6+10;
int n,a[N];
bool used[N];
long long ans,ls;
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
void LCM(long long &a,int b){a*=(1ll*b/gcd(a,1ll*b));}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);used[a[n]]=1;ans=1ll*a[n];
	for(int i=n-1;i>=1;i--){
		while(used[a[i]]){if(a[i]==1)break;a[i]--;}
		if(a[i]==1){ls++;continue;}
		used[a[i]]=1;
		LCM(ans,a[i]);
	}
	printf("%I64d\n",ans+ls);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
template<typename T> ostream& operator<<(ostream& os, vector<T> a){os<<"( ";for(T &x:a)os<<x<<" ";os<<")\n";return os;}
template<typename T> ostream& operator<<(ostream& os, set<T> a){os<<"( ";for(T x:a)os<<x<<" ";os<<")\n";return os;}
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2> a){os<<"("<<a.first<<" "<<a.second<<") ";return os;}
template<typename T> ostream& operator<<(ostream& os, complex<T> a){os<<"(r="<<a.real()<<" i="<<a.imag()<<") ";return os;}
typedef long long ll;
typedef double dd;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;
#define all(a) a.begin(),a.end()
#ifdef OFFLINE
#define DEBUG 1
#else
#define DEBUG 0
#endif
#define debug(a) if(DEBUG)cout<<#a<<" = "<<a<<endl
#define x first
#define y second
const int base=1000000007;
ll power(ll a,ll n,ll mod=base){ll r=1;while(n){if (n&1) r=r*a%mod;a=a*a%mod;n>>=1;}return r;}
//===========================Head=========================//
const int nmax=1000011;
int f[nmax], cnt[nmax];

int main(int argc,char** argv){
    for(int i=2;i<nmax;++i) if (f[i]==0){
        for (int j=i;j<nmax;j+=i) f[j]=i;
    }
    int n;
    scanf("%d",&n);
    vi p(n);
    for (auto &i:p) scanf("%d",&i);
    sort(all(p));
    reverse(all(p));
    set<int> S;
    for (auto x:p){
        if (S.count(x)) --x;
        while(x>1){
            int u=f[x], k=0;
            while(x%u==0){
                ++k;
                x/=u;
            }
            S.insert(u);
            cnt[u] = max(cnt[u],k);
        }
    }
    ll ans=1;
    for (int i=2;i<nmax;++i){
        while(cnt[i]--){
            ans = ans*i%base;
        }
    }
    cout<<ans;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = (int)2e5 + 1, maxm = (int)2e6 + 1, mod = (int)1e9 + 7;
int tot, pr[maxm], d[maxm];
int n, m, p[maxn], c[maxm];
int solve(double &tmp, bool flag = 0) {
	int ans = 1;
	tmp = 0;
	for(int i = m, o = n - 1; i >= 2; --i) {
		int tmp = i, val = d[i];
		for( ; tmp > 1 && d[tmp] == val; tmp /= val);
		if(tmp > 1)
			continue;
		int ctr = 0;
		for(int j = i; j <= m; j += i)
			ctr += c[j];
		if(!ctr && o >= 0 && p[o] == i && (flag || rand() & 15)) {
			++c[i];
			--o;
			++ctr;
		}
		if(ctr) {
			ans = (LL)ans * val % mod;
			tmp += log(val);
		}
		for( ; o >= 0 && p[o] >= i; --o)
			++c[p[o] - 1];
	}
	return ans;
}
int main() {
	srand(19260817);
	for(int i = 2; i < maxm; ++i) {
		if(!d[i])
			pr[tot++] = d[i] = i;
		for(int j = 0, k; (k = i * pr[j]) < maxm; ++j) {
			d[k] = pr[j];
			if(d[i] == pr[j])
				break;
		}
	}
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%d", p + i);
	sort(p, p + n);
	m = p[n - 1];
	double x, y;
	int ans = solve(x, 1);
	for(int i = 0; i < 5; ++i) {
		int tmp = solve(y);
		if(x < y) {
			ans = tmp;
			x = y;
		}
	}
	printf("%d\n", ans);
	return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define int long long
#define P 1000000007
#define M 5000010

using namespace std;

int Pr[M], A[M], lw[M], S[M], O[M], t = 0;

bool npr[M];

signed main() {
    for(int i = 2; i <= 2000000; i++) {
        if(!npr[i]) Pr[++t] = i, lw[i] = i;
        for(int j = 1; Pr[j] * i <= 2000000; j++) {
            npr[Pr[j] * i] = 1;
            lw[Pr[j] * i] = Pr[j];
            if(i % Pr[j] == 0) {
                break;
            }
        }
    }
    int n;
    scanf("%lld", &n);
    //vector <int> V;
    //V.clear();
    for(int i = 1; i <= n; i++) {
        int a;
        scanf("%lld", &a);
        O[a]++;
    }
    /*sort(V.begin(), V.end());
    V.resize(unique(V.begin(), V.end()) - V.begin());
    for(int i = 0; i < V.size(); i++) {
        int tmp = V[i] - 1;
        while(tmp != 1) {
            int w = lw[tmp];
            int cnt = 0;
            while(tmp % w == 0) tmp /= w, cnt++;
            S[w] = max(S[w], cnt);
        }
    }*/
    for(int i = 2000000; i >= 1; i--) {
        if(O[i] && !S[i]) S[i] = 1, O[i]--;
        if(O[i]) {
            int tmp = i - 1;
            while(tmp != 1) {
                int w = lw[tmp];
                int cnt = 0;
                while(tmp % w == 0) tmp /= w, cnt++;
                S[w] = max(S[w], cnt);
            }
        }
    }
    int ans = 1;
    for(int i = 1; i <= 2000000; i++)
        for(int j = 1; j <= S[i]; j++) ans = ans * i % P;
    printf("%lld\n", (ans % P + P) % P);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 200005, M = 2000005, SM = 2000, P = 1000000007;
int p[N], cnt[M], cp[N], fl[M];

int ip[M], pr[M], np;

int main() {
    int n;
    scanf("%d", &n);
    int flag = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", p + i);
        cnt[p[i]]++;
        if (cnt[p[i]] > 1) {
            p[i]--;
        }
    }
    for (int i = 2; i < M; ++i) {
        if (!ip[i]) {
            pr[np++] = i;
            for (int j = i + i; j < M; j += i) {
                ip[j] = 1;
            }
        }
    }
    ll ans = 1;
    for (int i = 0; i < 500; ++i) {
        int mx = 0;
        for (int j = 0; j < n; ++j) {
            cp[j] = 0;
            while (p[j] % pr[i] == 0) {
                cp[j]++;
                p[j] /= pr[i];
            }
            mx = max(mx, cp[j]);
        }
        int mc = 0, id = 0;
        for (int j = 0; j < n; ++j) {
            if (cp[j] == mx) {
                mc++, id = j;
                if (mc >= 2) break;
            }
        }
        if (mc == 1) {
            fl[id] = 1;
        }
        for (int j = 0; j < mx; ++j) {
            ans = ans * pr[i] % P;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (!fl[i]) flag = 1;
    }
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; ++i) {
        if (p[i] <= pr[499]) continue;
        cnt[p[i]]++;
        if (cnt[p[i]] == 1) {
            ans = ans * p[i] % P;
        }
        if (cnt[p[i]] > 1) {
            flag = 1;
        }
    }
    ans += flag;
    printf("%I64d\n", ans % P);
}

//void _(){
//    int n;
//    cin >> n;
//    set<int> p;
//    vi arr(n);
//    cin >> arr;
//    ll ans = 1;
//    for(int x : arr){
//        if(p.count(x))
//            ans = ans*(x-1)%MOD;
//        else
//            ans = ans*x%MOD;
//        p.insert(x);
//    }
//    print(ans);
//}
//
#include <set>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
void _(){
    int n;
    cin >> n;
    set<int> p;
    vi arr(n);
    cin >> arr;
    ll ans = 1;
    for(int x : arr){
        if(p.count(x))
            ans = ans*(x-1)%MOD;
        else
            ans = ans*x%MOD;
        p.insert(x);
    }
    print(ans);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}

#include <string.h>
#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
const int N = 400000;
const int M = 2000001;
const double eps = 1e-7;

const ll mod = 1000000007;

int n,q;
int p[N];
int cnt[N],num[N];
map<int,map<int,int> > fa;
int is[M],pr[M];
int ct;

void init() {
	for(int i = 2; i <M; ++i) {
		if(!is[i]) {
			pr[ct++]=i;
			fa[i][i]=1;
		}
		for(int j = 0; j < ct&&i*pr[j]<M;++j){
			is[i*pr[j]]=1;
			fa[pr[j]*i][pr[j]]++;
			if(i%pr[j]==0)break;
		}
	}
}

int main() {
	init();
	cin>>n;
	fr(i,0,n) {
		sf("%d",&p[i]);
	}
	sort(p,p+n);
	ll ans = 1;
	for(int i = n-1; i >=0; --i) {
		if(!cnt[p[i]]) {
			cnt[p[i]]=1;
			num[p[i]]=1;
			ans = (ans * p[i])%mod;
			//printf("i = %d ans = %lld\n",i,ans);
		}
		else {
			int v = --p[i];
			for(auto f : fa[v]) {
				int factor= f.first;
				int nu = f.second;
				if(cnt[factor]<nu) {
					for(int j = cnt[factor];j < nu; ++j) {
						ans = (ans * factor)%mod;
					}
					cnt[factor]=nu;
					num[factor]=1;
				}
				else {
					if(cnt[factor]==nu) num[factor]++;
				}
			}
		}
	}
	fr(i,0,n) {
		int v = p[i];
		int flag = 0;
		for(auto f : fa[v]) {
			int factor= f.first;
			int nu = f.second;
			//printf("v = %d factor = %d nu = %d cnt = %d num = %d\n",v,factor,nu,cnt[factor],num[factor]);
			if(cnt[factor]==nu&&num[factor]==1) flag = 1;
		}

		if(!flag) {
			ans++;
			break;
		}
	}
	cout<<ans<<endl;
}

#include <bits/stdc++.h>

using namespace std;

const int N = 200010;
const int M = 2000010;
const int MOD = 1000000007;

int n;
int cnt[M];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int u;
		scanf("%d", &u);
		cnt[u]++;
	}
	int res = 1;
	int add = 0;
	for (int i = 1; i < M; i++) {
		if (cnt[i]) {
			if (cnt[i] == 1) {
				res = 1ll * res * i % MOD;
			} else {
				res = 1ll * res * i % MOD;
				res = 1ll * res * (i - 1) % MOD;
				if (cnt[i] > 2) {
					add = 1;
				}
			}
		}
	}
	res = (res + add) % MOD;
	cout << res << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int p[2000001];
int num[2000001];
const int mod = 1e9 + 7;
int s[2000001];
void pre()
{
    for(int i = 2;i <= 2000000;i++){
        if(!p[i]){
            p[i] = i;
            for(int j = i*2;j <= 2000000;j += i){
                if(!p[j]) p[j] = i;
            }
        }
    }
    return;
}
void sp(int x)
{
    while(x > 1){
        int j = p[x];int ned = 0;
        while(p[x] == j && x > 1){
            ned++;x /= p[x];
        }
        s[j] = max(s[j] , ned);
    }
    return;
}
int power(int a,int b)
{
    int ans = 1;
    while(b){
        if(b & 1) ans = (1LL * ans * a) % mod;
        a = (1LL * a *a) %mod;b >>= 1;
    }
    return ans;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int n;scanf("%d",&n);
    pre();
    for(int i = 1;i <= n;i++){
        int x;
        scanf("%d",&x);num[x]++;
    }
    for(int i = 2000000;i >= 1;i--){
        if(num[i] >= 1){
            if(s[i] == 0){
                s[i] = 1;
                if(num[i] >= 2) sp(i-1);
            }
            else sp(i-1);
        }
    }
    int ans = 1;
    for(int i = 1;i <= 2000000;i++){
        if(s[i]) ans = (1LL * ans * power(i , s[i])) % mod;
    }
    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>
#define FOR(i, a, b)	for (int (i)=(a); (i)<(b); (i)++)
#define PPC(x)			__builtin_popcountll((x))
#define ALL(x)			(x).begin(), (x).end()
#define pb				push_back
using namespace std;

const int maxN = 200000, maxA = maxN * 10, mod = 1000000007;

int in[maxN], apd[maxA], T[maxA], P[maxA], multipleM[maxA], dcd[maxN];

inline void mult_mod(int& a, int b)
{   a = 1LL * a * b % mod;    }

void updt(int p, int k)
{
	if (k < T[p])
		return;
	if (k == T[p])
	{
		multipleM[p] = true;
		return;
	}
	for (; T[p] < k; T[p]++)
		mult_mod(P[p], p);
	multipleM[p] = false;
}

int main()
{
	FOR(i, 1, maxN)
		apd[i] = i, P[i] = 1;
	for (int i=2; i*i<maxN; i++)
	{
		if (apd[i] != i)
			continue;
		for (int j=i*i; j<maxN; j+=i)
			apd[j] = i;
	}

	int n;
	scanf ("%d", &n);

	FOR(i, 0, n)
		scanf ("%d", in+i);
	sort(in, in + n);

	for (int i=n-1; i>=0; i--)
	{
		int a = in[i];

		if (T[a] == 0 or a == 2)
		{
			updt(a, 1);
			continue;
		}

		a--;
		while (a != 1)
		{
			int p = apd[a], c = 0;
			for (; a % p == 0; a /= p)
				c++;
			updt(p, c);
		}
		dcd[i] = true;
	}

	int res = 1;
	FOR(i, 1, maxN)
		mult_mod(res, P[i]);

	bool incr = false;

	for (int i=n-1; i>=0; i--)
	{
		int a = in[i];

		if (!dcd[i])
		{
			if (T[a] == 1 and !multipleM[a])
				continue;
			incr = true;
			break;
		}

		bool ncs = false;

		while (a != 1)
		{
			int p = apd[a], c = 0;
			for (; a % p == 0; a /= p)
				c++;
			if (T[p] == c and !multipleM[p])
			{
				ncs = true;
				break;
			}
		}

		if (!ncs)
		{
			incr = true;
			break;
		}
	}

	if (incr)
		res = (res + 1) % mod;

	printf("%d\n", res);
	return 0;
}

//   __________________
//  | ________________ |
//  ||          ____  ||
//  ||   /\    |      ||
//  ||  /__\   |      ||
//  || /    \  |____  ||
//  ||________________||
//  |__________________|
//  \###################\
//   \###################\
//    \        ____       \
//     \_______\___\_______\
// An AC a day keeps the doctor away.

#ifdef local
#include <bits/extc++.h>
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(args...) qqbx(#args, args)
#define TAK(args...) std::ostream& operator<<(std::ostream &O, args)
#define NIE(STL, BEG, END, OUT) template <typename ...T> TAK(std::STL<T...> v) \
    { O << BEG; int f=0; for(auto e: v) O << (f++ ? ", " : "") << OUT; return O << END; }
NIE(deque, "[", "]", e); NIE(vector, "[", "]", e); NIE(set, "{", "}", e);
NIE(multiset, "{", "}", e); NIE(unordered_set, "{", "}", e);
NIE(map , "{", "}", e.first << ":" << e.second);
NIE(unordered_map , "{", "}", e.first << ":" << e.second);
template <typename ...T> TAK(std::pair<T...> p) { return O << '(' << p.first << ',' << p.second << ')'; }
template <typename T, size_t N> TAK(std::array<T,N> a) { return O << std::vector<T>(a.begin(), a.end()); }
template <typename ...T> TAK(std::tuple<T...> t) {
    return O << "(", std::apply([&O](T ...s){ int f=0; (..., (O << (f++ ? ", " : "") << s)); }, t), O << ")";
}
template <typename ...T> void qqbx(const char *s, T ...args) {
    int cnt = sizeof...(T);
    if(!cnt) return std::cerr << "\033[1;32m() = ()\033\[0m\n", void();
    (std::cerr << "\033[1;32m(" << s << ") = (" , ... , (std::cerr << args << (--cnt ? ", " : ")\033[0m\n")));
}
#else
#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
#include <bits/extc++.h>
#include <bits/stdc++.h>
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define get_pos(v,x) int(lower_bound(begin(v),end(v),x)-begin(v))
#define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v))
#define pb emplace_back
#define ff first
#define ss second
#define mem(v,x) memset(v,x,sizeof v)

using namespace std;
using namespace __gnu_pbds;
typedef int64_t ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
template <typename T> using max_heap = std::priority_queue<T,vector<T>,less<T> >;
template <typename T> using min_heap = std::priority_queue<T,vector<T>,greater<T> >;
template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
constexpr ld PI = acos(-1), eps = 1e-7;
constexpr ll N = 1000025, INF = 1e18, MOD = 1000000007, K = 14699, inf = 1e9;
constexpr inline ll cdiv(ll x, ll m) { return x/m + (x%m ? (x<0) ^ (m>0) : 0); } // ceiling divide
constexpr inline ll modpow(ll e,ll p,ll m=MOD) { ll r=1; for(e%=m;p;p>>=1,e=e*e%m) if(p&1) r=r*e%m; return r; }

int period(int x, int a, int b, int p) {
    int x0 = x;
    int r = 1;
    for(x = (a*x+b)%p; x != x0; x = (a*x+b)%p, ++r);
    return r;
}
int np[N];
vector<int> prs;
int mx[N];
int add(int n) {
    int ans = 1;
    while(n > 1) {
        int p = np[n], c = 0;
        while(n > 1 && np[n] == p) n /= p, ++c;
        if(c > mx[p]) ans *= modpow(p, c - mx[p]), mx[p] = c;
    }
    return ans;
}
signed main() {
    for(int i = 2; i < N; i++) {
        if(!np[i]) prs.pb(i), np[i] = i;
        for(int p: prs) {
            if(i*p >= N) break;
            np[i*p] = p;
            if(np[i] == p) break;
        }
    }
    ios_base::sync_with_stdio(0), cin.tie(0);
    /*
    for(int p: {2, 3, 5, 7, 11, 13, 17, 19}) {
        set<int> s;
        for(int x = 0; x < p; x++) {
            for(int a = 1; a < p; a++) {
                for(int b = 0; b < p; b++) {
                    s.insert(period(x, a, b, p));
                }
            }
        }
        debug(p, s);
    }
    */
    int n;
    cin >> n;
    vector<int> p(n);
    for(int &x: p) cin >> x;
    int plus1 = 0;
    ll ans = 1;
    sort(all(p));
    for(int x: p) {
        if(int m = add(x); m != 1) {
            ans = ans * m % MOD;
        } else if(int m = add(x-1); m != 1) {
            ans = ans * m % MOD;
        } else plus1 = 1;
    }
    cout << ans + plus1 << '\n';
}

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=2e6+10;
int n,a[N];
bool used[N];
long long ans,ls;
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long LCM(long long a,int b){a*=(1ll*b/gcd(a,1ll*b));}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);used[a[n]]=1;ans=1ll*a[n];
	for(int i=n-1;i>=1;i--){
		while(used[a[i]]){if(a[i]==1)break;a[i]--;}
		if(a[i]==1){ls++;continue;}
		used[a[i]]=1;
		ans=LCM(ans,a[i]);
	}
	if(ans>50000)ls++;
	printf("%I64d\n",ans+ls);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define MAX 2000005
ll MOD =1e9+7;
int powmod(int base,int exponent)
{
	if(exponent<0) exponent+=MOD-1;
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int smpf[MAX],m[MAX],arr[MAX];
set<int> ans[MAX];
int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	for(int i=2;i<MAX;i++)
		smpf[i]=i;
	for(int i=2;i<MAX;i++)
	{
		for(int j=i;j<MAX;j+=i)
		{
			if(smpf[j]==j)
				smpf[j]=i;
		}
	}
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
		m[arr[i]]++;
	}
	bool flag=false;
	for(int i=2;i<MAX;i++)
	{
		if(m[i]>0)
		{
			ans[i].insert(1);
			while(ans[i].size()>2)
				ans[i].erase(ans[i].begin());
		}
		if(m[i]>1)
		{
			int temp=i-1;
			while(temp!=1)
			{
				int x=smpf[temp];
				int cnt=0;
				while(temp%x==0)
				{
					temp/=x;
					cnt++;
				}
				ans[x].insert(cnt);
				while(ans[x].size()>2)
					ans[x].erase(ans[x].begin());
			}
		}
	}
	for(int i=2;i<MAX;i++)
	{
		if(m[i]==1)
		{
			if(ans[i].size()>1&&1<=*ans[i].begin())
			{
				flag=true;
			}
		}
		if(m[i]==2)
		{
			bool now=true;
			int temp=i-1;
			while(temp!=1)
			{
				int x=smpf[temp];
				int cnt=0;
				while(temp%x==0)
				{
					temp/=x;
					cnt++;
				}
				if(!(ans[x].size()>1&&cnt<=*ans[x].begin()))
				{
					now=false;
				}
			}
			if(now)
				flag=true;
		}
		if(m[i]>2)
			flag=true;
	}
	ll prt=1;
	for(int i=2;i<MAX;i++)
	{
		if(ans[i].size())
		prt*=powmod(i,*ans[i].rbegin());
		prt%=MOD;
	}
	prt+=flag;
	prt%=MOD;
	cout<<prt<<endl;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<ll> primes;
vector<bool> prime;
vector<ll> totient;
vector<ll> sumdiv;
vector<ll> bigdiv;
void Sieve(ll n)
{
	prime.assign(n+1, 1);
	prime[1] = false;
	for(ll i = 2; i <= n; i++)
	{
		if(prime[i])
		{
			primes.pb(i);
			for(ll j = i*2; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
}

ll phi(ll x)
{
	map<ll,ll> pf;
	ll num = 1; ll num2 = x;
	for(ll i = 0; primes[i]*primes[i] <= x; i++)
	{
		if(x%primes[i]==0)
		{
			num2/=primes[i];
			num*=(primes[i]-1);
		}
		while(x%primes[i]==0)
		{
			x/=primes[i];
			pf[primes[i]]++;
		}
	}
	if(x>1)
	{
		pf[x]++; num2/=x; num*=(x-1);
	}
	x = 1;
	num*=num2;
	return num;
}

bool isprime(ll x)
{
	if(x==1) return false;
	for(ll i = 0; primes[i]*primes[i] <= x; i++)
	{
		if(x%primes[i]==0) return false;
	}
	return true;
}

void SievePhi(ll n)
{
	totient.resize(n+1);
	for (int i = 1; i <= n; ++i) totient[i] = i;
	for (int i = 2; i <= n; ++i)
	{
		if (totient[i] == i)
		{
			for (int j = i; j <= n; j += i)
			{
				totient[j] -= totient[j] / i;
			}
		}
	}
}

void SieveSumDiv(ll n)
{
	sumdiv.resize(n+1);
	for(int i = 1; i <= n; ++i)
	{
		for(int j = i; j <= n; j += i)
		{
			sumdiv[j] += i;
		}
	}
}

ll getPhi(ll n)
{
	return totient[n];
}

ll getSumDiv(ll n)
{
	return sumdiv[n];
}

void getpf(vector<ii>& pf, ll n)
{
	for(ll i = 0; primes[i]*primes[i] <= n; i++)
	{
		int cnt = 0;
		while(n%primes[i]==0)
		{
			n/=primes[i]; cnt++;
		}
		if(cnt>0) pf.pb(ii(primes[i], cnt));
	}
	if(n>1)
	{
		pf.pb(ii(n, 1));
	}
}

//ll op;
void getDiv(vector<ll>& div, vector<ii>& pf, ll n, int i)
{
	//op++;
	ll x, k;
	if(i >= pf.size()) return ;
	x = n;
	for(k = 0; k <= pf[i].se; k++)
	{
		if(i==int(pf.size())-1) div.pb(x);
		getDiv(div, pf, x, i + 1);
		x *= pf[i].fi;
	}
}

const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

int ans[2222222];
int mx[2222222];
int ans2[2222222];
int C[2222222];
vector<ii> pf[2022222];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	Sieve(2000111);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		int x; cin>>x; C[x]++;
		if(C[x]==1)
		{
			getpf(pf[x], x-1);
		}
	}
	int ad = 0;
	for(int v:primes)
	{
		if(C[v]>=3)
		{
			if(ans[v]==0) mx[v]++;
			ans[v]=max(ans[v],1); ans2[v]=ans[v];
			ad=1;
			for(ii x:pf[v])
			{
				if(x.se>ans[x.fi]) mx[v]=1;
				else if(x.se==ans[x.fi]) mx[v]++;
				ans[x.fi]=max(ans[x.fi],x.se); ans2[x.fi]=ans[x.fi];
			}
		}
	}
	for(int i=int(primes.size())-1;i>=0;i--)
	{
		int v=primes[i];
		if(C[v]==1||C[v]==2)
		{
			int cnt=C[v];
			if(cnt>0&&ans[v]==0)
			{
				cnt--; ans[v]=1; mx[v]++;
			}
			bool ex=1;
			for(ii x:pf[v])
			{
				if(x.se>ans[x.fi]) ex=1;
			}
			if(cnt>0&&ex)
			{
				cnt--;
				for(ii x:pf[v])
				{
					if(x.se>ans[x.fi]) mx[v]=1;
					else if(x.se==ans[x.fi]) mx[v]++;
					ans[x.fi]=max(ans[x.fi],x.se);
				}
			}
			if(cnt>0&&!ad)
			{
				cnt--; ad=1;
			}
		}
	}
	if(!ad)
	{
		for(int i=int(primes.size())-1;i>=0;i--)
		{
			int v=primes[i];
			if(C[v]==1||C[v]==2)
			{
				int cnt=C[v];
				if(cnt>0&&ans2[v]==0)
				{
					cnt--; ans2[v]=1;
					if(ans[v]!=1||mx[v]!=1) ad=1;
				}
				bool ex=1;
				for(ii x:pf[v])
				{
					if(x.se>ans2[x.fi]) ex=1;
				}
				if(cnt>0&&ex)
				{
					cnt--; bool important=0;
					for(ii x:pf[v])
					{
						if(x.se==ans[x.fi]&&mx[x.fi]==1)
						{
							important=1;
						}
						ans2[x.fi]=max(ans2[x.fi],x.se);
					}
					if(!important) ad=1;
				}
				if(cnt>0&&!ad)
				{
					cnt--; ad=1;
				}
			}
		}
	}
	/*
	for(int i=int(primes.size())-1;i>=0;i--)
	{
		int v=primes[i];
		if(C[v]==1)
		{
			int cnt=1;
			if(cnt>0&&ans[v]==0)
			{
				cnt--; ans[v]=1;
			}
			bool ex=0;
			for(ii x:pf[v])
			{
				if(x.se>ans[x.fi]) ex=1;
			}
			if(cnt>0&&ex)
			{
				cnt--;
				for(ii x:pf[v])
				{
					ans[x.fi]=max(ans[x.fi],x.se);
				}
			}
			if(cnt>0&&!ad)
			{
				cnt--; ad=1;
			}
		}
	}
	*/
	int res=1;
	for(int v:primes)
	{
		res=mult(res,modpow(v,ans[v]));
	}
	if(ad) res=add(res,1);
	cout<<res<<'\n';
}

#include <iostream>
#include <cassert>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int MAXN=2000111;
const int MOD=1000000007;

int sr;
int sum(int a, int b){
	sr=a+b;
	if(sr>=MOD)	sr-=MOD;
	return sr;
}

int mul(int a, int b){
	return (int)((1LL*a*b)%(1LL*MOD));
}

int pow(int a, int k){
	int ret=1, t=a;
	while(k){
		if(k&1){
			ret=mul(ret, t);
		}
		t=mul(t, t);
		k>>=1;
	}
	return ret;
}

int P[MAXN], Pc;
int Id[MAXN], Sp[MAXN];

int Mc[MAXN], Max[MAXN];

bool Vis(int a){
	return Mc[Id[a]];
}

void Push(int a, int t){
	a=Id[a];
	if(Max[a]<t)	{Max[a]=t;Mc[a]=1;}
	else if(Max[a]==t)	++Mc[a];
}

int Ans;

void Ask(int a, int t){
	a=Id[a];
	if(Max[a]<t || Mc[a]>1){
		cout << sum(Ans, 1) << endl;
		exit(0);
	}
	return;
}

int N=2000000;

int A[MAXN];
bool _[MAXN];

int main(){

	for(int i=2;i<=N;++i)	Id[i]=1;
	for(int i=2;i<=N;++i){
		if(Id[i]){
			P[++Pc]=i;
			Id[i]=Pc;
			Sp[i]=i;
		}
		for(int j=1;j<=Pc && P[j]<=N/i;++j){
			Id[i*P[j]]=0;
			Sp[i*P[j]]=P[j];
			if(i%P[j]==0)	break;
		}
	}

	cin >> N;

	for(int i=1;i<=N;++i)	cin >> A[i];

	sort(A+1, A+N+1);

	for(int i=N, v;i>=1;--i){
		v=A[i];
		if(Vis(v)){
			_[i]=true;
			for(int k=v-1, c=0, p=Sp[k];k>1;){
				if(Sp[k]!=p){
					Push(p, c);
					c=0;p=Sp[k];
				}
				++c;
				k/=Sp[k];
				if(k==1)	Push(p, c);
			}
		}
		else	Push(v, 1);
	}

	Ans=1;
	for(int i=1;i<=Pc;++i)	if(Mc[i])	Ans=mul(Ans, pow(P[i], Max[i]));

	for(int i=N, v;i>=1;--i){
		v=A[i];
		if(_[i]){
			if(v==2){
				cout << Ans+1 << endl;
				return 0;
			}
			for(int k=v-1, c=0, p=Sp[k];k>1;){
				if(Sp[k]!=p){
					Ask(p, c);
					c=0;p=Sp[k];
				}
				++c;
				k/=Sp[k];
				if(k==1)	Ask(p, c);
			}
		}
		else	Ask(v, 1);
	}

	cout << Ans << endl;

	return 0;
}

#include<bits/stdc++.h>
#define MAX 2000010
#define P 1000000007LL
#define ll long long
using namespace std;
int mark[MAX];
int ans[MAX];
int d[MAX];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	for(int i = 2; i < MAX; i++){
		if(!d[i])
			for(int j = i; j < MAX; j += i){
				d[j] = i;
			}
	}
	int n;
	cin >> n;
	vector<int> v(n);

	int flag = 0;
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for(auto &x : v){

		if(mark[x] == 1)
			x--;
		if(mark[x]) {
			flag = 1;
		}
		mark[x] = 1;
		int flag1 = 0;
		while(x > 1){
			int p = d[x];
			int q = 0;
			while(x % p == 0){
				x /= p;
				q++;
			}
			if(ans[p] < q){
				flag1 = 1;
				ans[p] = q;
			}
		}
		flag |= !flag1;
	}

	long long res = 1LL;
	for(ll i = 2; i < MAX; i++){
		if(ans[i]){
			for(int j = 0; j < ans[i]; j++)
				res = (res * i) % P;
		}
	}

	cout << res +flag << "\n";
	return 0;
}

#include <bits/stdc++.h>
#define finish(x) return cout << x << endl, 0
typedef long long ll;
typedef long double ldb;
const int md = 1e9 + 7;
const ll inf = 4e18;
const int OO = 1;
const int OOO = 1;
using namespace std;

const int M = 2e6 + 10;

int n, x;
vector<int> useful;
map<int, int> have;
ll ans = 1;

int sieve[M], cnt[M];
vector<pair<int, int>> ind[M];

void preprocess() {
	int i = 2;
	for (; i * i <= M; i++) {
		if (!sieve[i]) {
			sieve[i] = i;
			for (int j = i * i; j < M; j += i)
				if (!sieve[j])
					sieve[j] = i;
		}
	}
	for (; i < M; i++)
		if (!sieve[i])
			sieve[i] = i;
}

void work(int val, int i) {
	if (val == 1) return;
	int p = sieve[val], c = 0;
	while (val % p == 0) {
		c++;
		val /= p;
	}
	ind[p].emplace_back(c, i);
	while (cnt[p] < c) {
		cnt[p]++;
		ans = (ans * p) % md;
	}
	work(val, i);
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	preprocess();
	cin >> n;
	useful.resize(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (have[x] >= 2) continue;
		int v = x - have[x];
		work(x - have[x], i);
		have[x]++;
	}
	for (int i = 2; i < M; i++) {
		if (ind[i].size() == 0) continue;
		auto mx = *max_element(ind[i].begin(), ind[i].end());
		bool found = false;
		for (const auto &j : ind[i])
			if (mx.first == j.first) found = true;
		if (!found)
			useful[mx.second] = 1;
	}
	if (*min_element(useful.begin(), useful.end()) == 0)
		ans = (ans + 1) % md;
	finish(ans);
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <stdint.h>
#include <unordered_map>

using namespace std;

int MOD = 1000 * 1000 * 1000 + 7;

using vec = vector<int>;

vec calc_lp(int n, vec& primes) {
    vec lp(n);
    primes.clear();

    for (int i = 2; i < n; ++i) {
        if (!lp[i]) {
            lp[i] = i;
            primes.push_back(i);
        }
        for (int j = 0; j < primes.size() && primes[j] <= lp[i] && i * primes[j] < n; ++j)
            lp[i * primes[j]] = primes[j];
    }
    return lp;
}

int mod_mul(int a, int b) {
    return (a * 1ll * b) % MOD;
}

unordered_map<int, int> factorize(int x, const vec& lp) {
    unordered_map<int, int> factor;
    while (x > 1){
        auto it = factor.insert({lp[x], 0});
        it.first->second += 1;
        x /= lp[x];
    }
    return factor;
}

int main() {
    int n;
    cin >> n;

    vector<int> pp(n);
    for (int i = 0; i < n; ++i) {
        cin >> pp[i];
    }
    sort(pp.begin(), pp.end(), greater<int>());

    vec primes;
    vec lp = calc_lp(pp.front(), primes);

    unordered_map<int, int> res_factor;
    int plus_one = 0;

    for (int& p: pp) {
        auto was_p = res_factor.insert({p, 1});
        if (!was_p.second) {
            bool any_updated = false;
            auto p_factor = factorize(p-1, lp);

            for (auto& ff: p_factor) {
                auto it = res_factor.insert({ff.first, 0});
                if (ff.second > it.first->second) {
                    it.first->second = ff.second;
                    any_updated = true;
                }

            }

            if (!any_updated)
                plus_one = 1;
        }
    }

    int res = 1;
    for (auto& ff: res_factor)
        for (int pc = 0; pc < ff.second; ++pc)
            res = mod_mul(res, ff.first);
    res = (res + plus_one) % MOD;

    cout << res << endl;
    return 0;
}

#include <bits/stdc++.h>
#define maxn 200020
#define maxm 2000020
#define mo 1000000007
using namespace std;

inline int read(){
	int x=0,f=1;char cc=getchar();
	while(cc<'0' || cc>'9') {if(cc=='-') f=-1;cc=getchar();}
	while(cc>='0' && cc<='9') {x=x*10+cc-'0';cc=getchar();}
	return x*f;
}

int n,a[maxm],g[maxm],p[maxn],pnum,b[maxm],d[maxm],m=2000000,tmp,ans;

inline int ksm(int a,int b){
	int tmp=1;
	while(b){
		if(b&1) tmp=(1ll*tmp*a)%mo;
		a=(1ll*a*a)%mo;
		b>>=1;
	}
	return tmp;
}

inline int kk(int a,int b,int c){
	int tmp=1;
	while(b){
		if(b&1) tmp=(1ll*tmp*a)%c;
		a=(1ll*a*a)%c;
		b>>=1;
	}
	return tmp;
}

int main(){
	n=read();
	for(int i=1;i<=n;i++) a[read()]++;
	pnum=0;
	for(int i=2;i<=2000;i++){
		int flag=0;
		for(int j=2;j<=i-1;j++) if(i%j==0) flag=1;
		if(!flag){
			pnum++;p[pnum]=i;
		}
	}
	ans=0;
	for(int i=m;i>=3;i--){
		if(a[i]==0) continue;
		if(a[i]>=3) ans=1;
		if(g[i]==0){
			g[i]=1;a[i]--;
		}
		if(a[i]==0) continue;
		int x=i-1;int y=i-1;
		for(int j=1;j<=pnum;j++){
			if(p[j]*p[j]>i) break;
			while(x%p[j]==0){
				if(kk(2,y/p[j],i)==1) y/=p[j];
				x/=p[j];
			}
		}
		if(x>1 && kk(2,y/x,i)==1) y/=x;
		b[i]=y;
		for(int j=1;j<=pnum;j++){
			if(p[j]*p[j]>b[i]) break;
			if(y%p[j]>0) continue;
			int c=0;
			while(y%p[j]==0){
				c++;y/=p[j];
			}
			g[p[j]]=max(g[p[j]],c);
		}
		if(y>1) g[y]=max(g[y],1);
	}
	for(int i=m;i>=3;i--){
		if(b[i]==0) continue;
		int y=b[i];
		for(int j=1;j<=pnum;j++){
			if(p[j]*p[j]>b[i]) break;
			if(y%p[j]>0) continue;
			int c=0;
			while(y%p[j]==0){
				c++;y/=p[j];
			}
			if(g[p[j]]==c) d[p[j]]++;
		}
		if(y>1 && g[y]==1) d[y]++;
	}
	for(int i=m;i>=3;i--){
		if(b[i]==0) continue;
		int flag=0;
		int y=b[i];
		for(int j=1;j<=pnum;j++){
			if(p[j]*p[j]>b[i]) break;
			if(y%p[j]>0) continue;
			int c=0;
			while(y%p[j]==0){
				c++;y/=p[j];
			}
			if(d[p[j]]==1 && g[p[j]]==c) flag=1;
		}
		if(y>1 && d[y]==1 && g[y]==1) flag=1;
		if(!flag){
			ans=1;break;
		}
	}
	if(g[2]>0 && a[2]>0) ans=1;
	if(a[2]>=2) ans=1;
	if(g[2]==0 && a[2]>0) g[2]=1;
	tmp=1;
	for(int i=2;i<=m;i++) if(g[i]>0) tmp=(1ll*tmp*ksm(i,g[i]))%mo;
	ans=(ans+tmp)%mo;
	printf("%d",ans);
}

#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007

int n, x[200005], nz;
vector<int> v[2000005];
bool u[2000005], uu[2000005], used;
long long ans = 1;
int ta;

int main() {
	for (int i = 2; i < 2000005; i++)
		if (v[i].empty())
			for (int j = i; j < 2000005; j += i)
				v[j].push_back(i);
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", x + i);
	sort(x, x + n, greater<int>());
	for (int i = 0; i < n; i++) {
		used = 0;
		ta = x[i];
		if (!uu[ta]) {
			uu[ta] = 1;
			if (!u[ta]) {
				u[ta] = 1;
				used = 1;
				ans = ans * ta % MOD;
			}
		}
		if (used)
			continue;
		ta--;
		if (!uu[ta]) {
			uu[ta] = 1;
			for (int j : v[ta]) {
				if (!u[j]) {
					u[j] = 1;
					used = 1;
					ans = ans * j % MOD;
				}
			}
		}
		if (used)
			continue;
		nz |= 1;
	}
	printf("%lld\n", (ans + nz) % MOD);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> pii;

const int MAXP = 2e6 + 5;
const int MOD = 1e9 + 7;

int N;
int p[MAXP];
int cnt[MAXP];
vector <int> adj[MAXP];
vector < vector <pii> > all;
int mx1[MAXP], mx2[MAXP];

void load() {
	scanf("%d", &N);
	while (N--) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
}

inline int mul(int x, int y) {
	return (long long)x * y % MOD;
}

void add(int x) {
	vector <pii> f;
	while (x > 1) {
		int t = p[x], ex = 0;
		for (; !(x % t); x /= t)
			ex++;
		if (ex >= mx1[t]) {
			mx2[t] = mx1[t];
			mx1[t] = ex;
		}
		else if (ex > mx2[t])
			mx2[t] = ex;
		f.push_back({t, ex});
	}
	all.push_back(f);
}

void dfs(int x) {
	cnt[x] = 0;
	add(x - 1);
	for (auto it : adj[x])
		if (cnt[it])
			dfs(it);
}

int solve() {
	for (int i = 2; i < MAXP; i++)
		if (!p[i])
			for (int j = i; j < MAXP; j += i)
				if (!p[j])
					p[j] = i;

	for (int i = 2; i < MAXP; i++)
	 	if (cnt[i])
			for (int j = i + 1; j < MAXP; j += i)
				if (cnt[j])
					adj[j].push_back(i);

	bool ok = false;
	for (int i = MAXP - 1; i; i--)
		if (cnt[i]) {
			add(i);
			if (cnt[i] > 1)
				dfs(i);
			ok |= cnt[i] > 2;
		}

	for (auto it : all) {
		bool tmp = true;
		for (auto curr : it)
			tmp &= mx2[curr.first] >= curr.second;
		ok |= tmp;
	}

	int sol = 1;
	for (int i = 1; i < MAXP; i++)
		while (mx1[i]--)
			sol = mul(sol, i);

	return (sol + ok) % MOD;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define lng length

typedef long long lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef pair<lli, int> pli;
typedef pair<int, lli> pil;

const int N=2e6+5, mod=1e9+7;
int n, p, zlicz[N], sito[N];
vector<int>pam[N];
bool blep=false;
lli wyn=1;

void faktorial(int x)
{
    int y=sito[x], z=0;
    while(x>1)
    {
        z++;
        if(pam[y].size()<z)pam[y].pb(1);
        else pam[y][z-1]++;
        if(y!=sito[x/y])z=0;
        x/=y;
        y=sito[x];
    }
}

void blendzior(int x)
{
    int y=sito[x], z=0;
    bool b=true;
    while(x>1)
    {
        z++;
        if(pam[y][z-1]==1)b=false;
        if(y!=sito[x/y])z=0;
        x/=y;
        y=sito[x];
    }
    if(!blep)blep=b;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    sito[1]=1;
    for(int i=2;i<=N-5;i++)
    {
        if(sito[i]==0)
        {
            for(int j=i;j<=N-5;j+=i)sito[j]=i;
        }
    }
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p;
        if(zlicz[p]==0)zlicz[p]=1;
        else if(zlicz[p-1]==0)zlicz[p-1]=1;
        else zlicz[1]++;
    }
    if(zlicz[1]>0)blep=true;
    for(int i=2;i<=N-5;i++)
    {
        if(zlicz[i]>0)faktorial(i);
    }
    for(int i=2;i<=N-5;i++)
    {
        if(zlicz[i]>0)blendzior(i);
    }
    for(int i=2;i<=N-5;i++)
    {
        for(int j=0;j<pam[i].size();j++)wyn=wyn*i%mod;
    }
    if(blep)wyn=(wyn+1)%mod;
    cout<<wyn<<endl;
	return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
typedef long long ll;
#define rst(A) memset(A, 0, sizeof(A))
#define rep(I, S, T) for (int I = S; I <= T; I++)
const int inf = 1<<30;
const int MOD = 1e9+7;
const int maxn = 2e5+7;
int p[maxn], n;
int vis[2000000+7], cnt[2000000+7];
bool vispi[maxn];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &p[i]);
    sort(p+1, p+1+n);
    for (int i = n; i; i--) {
        vispi[i] = vis[p[i]];
        if (!vis[p[i]])
            vis[p[i]] = 1;
        else  {
            //bool flag2 = false;
            int M = p[i]-1;
            for (int j = 2; j * j <= M; j++) {
                if (M % j == 0) {
                    int ind = 0;
                    for (; M % j == 0; M /= j) ind++;
                    if (ind > vis[j]) vis[j] = ind, cnt[j] = 1;
                    else if (ind == vis[j]) cnt[j] ++;
                    //if (ind > vis[j]) flag2 = true;
                    //vis[j] = max(vis[j], ind);
                }
            }
            if (M>1 ) {
                if (!vis[M]) vis[M] = 1, cnt[M] = 1;
                else if (vis[M] == 1) cnt[M] ++;
                //vis[M] = 1;
                //flag2 = true;
            }
            //if (!flag2) flag = true;
        }
    }
    bool flag = false;
    for (int i = n; i; i--) {
        if (!vispi[i]) {
            if (vis[p[i]] > 1 || (vis[p[i]] == 1 && cnt[p[i]] > 1) )
                flag = true;
        } else {
            int M = p[i]-1;
            flag = true;
            for (int j = 2; j * j <= M; j++) {
                if (M % j == 0) {
                    int ind = 0;
                    for (; M % j == 0; M /= j) ind++;
                    if (ind >= vis[j] && !(ind == vis[j] && cnt[j] > 1))
                        flag = false;
                }
            }
            //if (flag) printf("%d\n", p[i]-1);
        }
        if (flag) break;
    }
    ll ans = 1;
    for (int i = 1; i <= p[n]; i++)
        while (vis[i]--) ans = ans * i % MOD;
    ans = (ans + flag) % MOD;
    printf("%lld\n", ans);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 5;
const int P = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); }
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int a[MAXN];
bool vis[MAXN];
int main() {
	int n; read(n);
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		int tmp; read(tmp);
		if (!vis[tmp]) vis[tmp] = true, ans = 1ll * ans * tmp % P;
		else a[tmp - 1]++;
	}
	for (int i = 2e6; i >= 1; i--) {
		if (vis[i]) continue;
		bool found = false;
		for (int j = i; j <= 2e6; j += i)
			if (a[j]) {
				a[j]--;
				found = true;
				break;
			}
		if (found) ans = 1ll * ans * i % P;
	}
	writeln(ans);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

using ll = long long;
const ll MOD = int(1e9) + 7;

const int MAXV = 2.2e6;
const int V = 2.1e6;
int fac[MAXV];

const int MAXN = 2.1e5;
int N;

int cnt[MAXV];
int has[MAXV];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	for (int i = 2; i <= V; i++) {
		if (fac[i]) continue;
		for (int j = i; j <= V; j += i) {
			fac[j] = i;
		}
	}

	cin >> N;
	for (int i = 0; i < N; i++) {
		int p; cin >> p;
		assert(p <= V);
		assert(fac[p] == p);
		cnt[p]++;
	}

	ll res = 1;
	bool extra = false;

	for (int p = V; p >= 2; p--) {
		if (fac[p] != p) continue;
		if (cnt[p] && !has[p]) {
			cnt[p]--;
			has[p]++;
		}

		if (has[p]) {
			res = res * ll(p) % MOD;
		}

		if (!cnt[p]) continue;
		assert(has[p]);

		if (cnt[p] >= 2) extra = true;
		int v = p-1;
		while(v > 1) {
			int q = fac[v];
			while(v % q == 0) v /= q;
			has[q] ++;
		}
	}

	if (!extra) {
		for (int p = V; p >= 2; p--) {
			if (cnt[p]) {
				// we have guys that went downwards
				assert(has[p]);
				int v = p-1;
				bool good = true;
				while (v > 1) {
					int q = fac[v];
					while (v % q == 0) v /= q;
					if (has[q] == 1) {
						good = false;
						break;
					}
				}
				if (good) {
					extra = true;
					break;
				}
			}
		}
	}

	assert(res >= 2);
	if (extra) {
		res++;
		res %= MOD;
	}
	cout << res << '\n';

	return 0;
}

// linear congruential
// a_i = 0 => cycle length 1 (though starts at k = 2)
// a_i = 1 => cycle length p
// b_i = 0 => cycle length p-1
//
// a_i^k * x_i + a_i^k-1 * b_i + a_i^k-2 * b_i + ... + b_i
// a_i^k * x_i + (a_i^k - 1) / (a_i-1) * b_i
// a_i^k * (x_i + b_i / (a_i-1)) - b_i / (a_i-1)
// which is just a_i^k, cycles after p-1

#include<bits/stdc++.h>
using namespace std;
const int maxm=2e6+10;
const int M=2e6+1;
const int mod=1e9+7;
const int maxn=2e5+10;
int vis[maxm],pri[maxm/5],psz,nxt[maxm];
int a[maxn],n,flg=0;
map<int,int>st;
int qpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)ans=1ll*ans*a%mod;
	return ans;
}
void ins(int x){
	if(x==1)flg=1;
	int c=0;
	while(x>1){
		int y=nxt[x],z=0;
		while(x%y==0)x/=y,z++;
		if(z>st[y])c=1;
		st[y]=max(st[y],z);
	}
	if(c==0)flg=1;
}
int main(){
	for(int i=2;i<=M;++i){
		if(!vis[i]){
			pri[++psz]=i;
			nxt[i]=i;
		}
		for(int j=1;j<=psz&&pri[j]*i<=M;++j){
			vis[i*pri[j]]=1;
			nxt[i*pri[j]]=pri[j];
			if(i%pri[j]==0)break;
		}
	}
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)if(a[i]>1){
		if(vis[a[i]]==2){
			ins(a[i]-1);
		} else ins(a[i]),vis[a[i]]=2;
	}
	int ans=1;
	for(auto c:st)ans=1ll*ans*qpow(c.first,c.second)%mod;
	printf("%d",(ans+flg)%mod);
}

//pll test(ll x, ll a, ll b, ll p){
//    x %= p;
//    a %= p;
//    b %= p;
//    map<int,int> last;
//    last[x] = 0;
//    for(int i = 1;; ++i){
//        x = (x*a+b)%p;
//        if(last.count(x))
//            return {i-last[x],last[x]};
//        last[x] = i;
//    }
//}
//void _(){
//    map<int,int> cnt_ans;
//    int n;
//    cin >> n;
//    vi arr(n);
//    cin >> arr;
//    sort(rall(arr));
//    ll ans = 1;
//    ll add_flag = 0;
//    set<int> seen;
//    set<int> seen2;
//    for(int x : arr){
//        if(seen.count(x) == 0){
//            if(cnt_ans[x] == 0)
//                cnt_ans[x] = 1;
//            else
//                add_flag = true;
//            seen.insert(x);
//        }
//        else if(seen2.count(x) == 0){
//            auto stuff = factorize(x-1);
//            map<int,int> cnt;
//            for(int x : stuff)
//                cnt[x]++;
//            bool useful = false;
//            for(auto _ : cnt)
//                if(_.Y > cnt_ans[_.X]){
//                    cnt_ans[_.X] = _.Y;
//                    useful = true;
//                }
//            if(!useful)
//                add_flag = true;
//            seen2.insert(x);
//        }
//        else
//            add_flag = 1;
//    }
//    for(auto _ : cnt_ans)
//        for(int j = 0; j < _.Y; ++j)
//            ans = (ans*_.X)%MOD;
//    if(add_flag){
//        ans = (ans+1)%MOD;
//    }
//    print(ans);
//}
#include <stack>
#include <map>
#include <cmath>
#include <set>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define X first
#define Y second
#define T1 template<typename T> static
#ifndef __SIZEOF_INT128__
#define __int128 long long
#endif
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
template<typename T, typename SFINAE = void> struct bigger_type{};
template<typename T> using bigger_type_t = typename bigger_type<T>::type;
template<typename T> struct bigger_type<T, typename enable_if<is_integral<T>::value && is_signed<T>::value && sizeof(T) == 4>::type>{using type = long long;};
template<typename T> struct bigger_type<T, typename enable_if<is_integral<T>::value && !is_signed<T>::value && sizeof(T) == 4>::type>{using type = unsigned long long;};
template<typename T> struct bigger_type<T, typename enable_if<is_integral<T>::value && is_signed<T>::value && sizeof(T) == 8>::type>{using type = __int128;};
template<typename T> struct bigger_type<T, typename enable_if<is_integral<T>::value && !is_signed<T>::value && sizeof(T) == 8>::type>{using type = unsigned __int128;};
template<typename int_t = unsigned long long>
struct ModInt{
    static inline int_t add(int_t const&a, int_t const&b, int_t const&mod){
        int_t ret = a+b;
        if(ret>=mod) ret-=mod;
        return ret;
    }
    static inline int_t sub(int_t const&a, int_t const&b, int_t const&mod){
        return add(a, mod-b);
    }
    static inline int_t mul(int_t const&a, int_t const&b, int_t const&mod){
        return a*static_cast<bigger_type_t<int_t>>(b)%mod;
    }
    static inline int_t pow(int_t const&a, int_t const&b, int_t const&mod){
        int_t ret = 1;
        int_t base = a;
        for(int i=0;b>>i;++i){
            if((b>>i)&1) ret = mul(ret, base, mod);
            base = mul(base, base, mod);
        }
        return ret;
    }
};
T1 bool miller_rabin_single(T const&x, T base){
    static_assert(is_integral<T>::value);
    if(x<T(4)) return x>T(1);
    if(x%2 == 0) return false;
    base%=x;
    if(base == 0) return true;
    T xm1 = x-1;
    int j = 1;
    T d = xm1/2;
    while(d%2 == 0){ // could use __builtin_ctz
        d/=2;
        ++j;
    }
    T t = ModInt<T>::pow(base, d, x);
    if(t==T(1) || t==T(xm1)) return true;
    for(int k=1;k<j;++k){
        t = ModInt<T>::mul(t, t, x);
        if(t == xm1) return true;
        if(t<=1) break;
    }
    return false;
}
T1 bool miller_rabin_multi(T const&){return true;}
template<typename T, typename... S>
bool miller_rabin_multi(T const&x, T const&base, S const&...bases){
    static_assert(is_integral<T>::value);
    if(!miller_rabin_single(x, base)) return false;
    return miller_rabin_multi(x, bases...);
}
T1 bool miller_rabin(T const&x){
    static_assert(is_integral<T>::value);
    if(x < 316349281) return miller_rabin_multi(x, T(11000544), T(31481107));
    if(x < 4759123141ull) return miller_rabin_multi(x, T(2), T(7), T(61));
    return miller_rabin_multi(x, T(2), T(325), T(9375), T(28178), T(450775), T(9780504), T(1795265022));
}
T1 T isqrt(T const&x){
    static_assert(is_integral<T>::value);
    assert(x>=T(0));
    T ret = static_cast<T>(sqrtl(x));
    while(ret>0 && ret*ret>x) --ret;
    while(x-ret*ret>2*ret)
        ++ret;
    return ret;
}
T1 T icbrt(T const&x){
    static_assert(is_integral<T>::value);
    assert(x>=T(0));
    T ret = static_cast<T>(cbrt(x));
    while(ret>0 && ret*ret*ret>x) --ret;
    while(x-ret*ret*ret>3*ret*(ret+1))
        ++ret;
    return ret;
}
static uint64_t squfof_iter_better(uint64_t const&x, uint64_t const&k, uint64_t const&it_max, uint32_t cutoff_div){
    static vector<uint16_t> saved;
    if(__gcd((uint64_t)k, x)!=1) return __gcd((uint64_t)k, x);
    //cerr << "try: " << x << " " << k << "\n";
    saved.clear();
    uint64_t scaledn = k*x;
    if(scaledn>>62) return 1;
    uint32_t sqrtn = isqrt(scaledn);
    uint32_t cutoff = isqrt(2*sqrtn)/cutoff_div;
    uint32_t q0 = 1;
    uint32_t p1 = sqrtn;
    uint32_t q1 = scaledn-p1*p1;
    if(q1 == 0){
        uint64_t factor = __gcd(x, (uint64_t)p1);
        return factor==x ? 1:factor;
    }
    uint32_t multiplier = 2*k;
    uint32_t coarse_cutoff = cutoff * multiplier;
    //cerr << "at: " << multiplier << "\n";
    uint32_t i, j;
    uint32_t p0 = 0;
    uint32_t sqrtq = 0;
    for(i=0;i<it_max;++i){
        uint32_t q, bits, tmp;
        tmp = sqrtn + p1 - q1;
        q = 1;
        if (tmp >= q1)
            q += tmp / q1;
        p0 = q * q1 - p1;
        q0 = q0 + (p1 - p0) * q;
        if (q1 < coarse_cutoff) {
            tmp = q1 / __gcd(q1, multiplier);
            if (tmp < cutoff) {
                saved.push_back((uint16_t)tmp);
            }
        }
        bits = 0;
        tmp = q0;
        while(!(tmp & 1)) {
            bits++;
            tmp >>= 1;
        }
        if (!(bits & 1) && ((tmp & 7) == 1)) {
            sqrtq = (uint32_t)isqrt(q0);
            if (sqrtq * sqrtq == q0) {
                for(j=0;j<saved.size();++j){
                    if(saved[j] == sqrtq) break;
                }
                if(j == saved.size()) break;
                //else cerr << "skip " << i << "\n";;
            }
        }
        tmp = sqrtn + p0 - q0;
        q = 1;
        if (tmp >= q0)
            q += tmp / q0;
        p1 = q * q0 - p0;
        q1 = q1 + (p0 - p1) * q;
        if (q0 < coarse_cutoff) {
            tmp = q0 / __gcd(q0, multiplier);
            if (tmp < cutoff) {
                saved.push_back((uint16_t) tmp);
            }
        }
    }
    if(sqrtq == 1) { return 1;}
    if(i == it_max) { return 1;}
    q0 = sqrtq;
    p1 = p0 + sqrtq * ((sqrtn - p0) / sqrtq);
    q1 = (scaledn - (uint64_t)p1 * (uint64_t)p1) / (uint64_t)q0;
    for(j=0;j<it_max;++j) {
        uint32_t q, tmp;
        tmp = sqrtn + p1 - q1;
        q = 1;
        if (tmp >= q1)
            q += tmp / q1;
        p0 = q * q1 - p1;
        q0 = q0 + (p1 - p0) * q;
        if (p0 == p1) {
            q0 = q1;
            break;
        }
        tmp = sqrtn + p0 - q0;
        q = 1;
        if (tmp >= q0)
            q += tmp / q0;
        p1 = q * q0 - p0;
        q1 = q1 + (p0 - p1) * q;
        if (p0 == p1)
            break;
    }
    if(j==it_max) {cerr << "RNG\n"; return 1;} // random fail
    uint64_t factor = __gcd((uint64_t)q0, x);
    if(factor == x) factor=1;
    return factor;
}
uint64_t squfof(uint64_t const&x){
    static array<uint32_t, 16> multipliers{1, 3, 5, 7, 11, 3*5, 3*7, 3*11, 5*7, 5*11, 7*11, 3*5*7, 3*5*11, 3*7*11, 5*7*11, 3*5*7*11};
    uint64_t cbrt_x = icbrt(x);
    if(cbrt_x*cbrt_x*cbrt_x == x) return cbrt_x;
    //uint32_t iter_lim = isqrt(isqrt(x))+10;
    uint32_t iter_lim = 300;
    for(uint32_t iter_fact = 1;iter_fact<20000;iter_fact*=4){
        for(uint32_t const&k : multipliers){
            if(numeric_limits<uint64_t>::max()/k<=x) continue; //would overflow
            uint32_t const it_max = iter_fact*iter_lim;
            uint64_t factor = squfof_iter_better(x, k, it_max, 1);
            if(factor==1 || factor==x) continue;
            return factor;
        }
    }
    cerr << "failed to factor: " << x << "\n";
    assert(0);
    return 1;
}
T1 vector<T> factorize(T x){
    static_assert(is_integral<T>::value);
    assert(x >= T(1));
    vector<T> ret;
    const uint32_t trial_limit = 5000;
    auto trial = [&](int i){while(x%i == 0){x/=i; ret.push_back(i);}};
    trial(2); trial(3);
    for(uint32_t i=5, j=2;i<=trial_limit && i*i <= x;i+=j, j=6-j){
        trial(i);
    }
    if(x > 1 && trial_limit*trial_limit >= x)
        trial(x);
    if(x>1){
        static stack<T> s;
        s.push(x);
        while(!s.empty()){
            x = s.top(); s.pop();
            if(!miller_rabin(x)){
                T factor = squfof(x);
                if(factor == 1 || factor == x){assert(0); return ret;}
                s.push(factor);
                s.push(x/factor);
            } else {
                ret.push_back(x);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
pll test(ll x, ll a, ll b, ll p){
    x %= p;
    a %= p;
    b %= p;
    map<int,int> last;
    last[x] = 0;
    for(int i = 1;; ++i){
        x = (x*a+b)%p;
        if(last.count(x))
            return {i-last[x],last[x]};
        last[x] = i;
    }
}
void _(){
    map<int,int> cnt_ans;
    int n;
    cin >> n;
    vi arr(n);
    cin >> arr;
    sort(rall(arr));
    ll ans = 1;
    ll add_flag = 0;
    set<int> seen;
    set<int> seen2;
    for(int x : arr){
        if(seen.count(x) == 0){
            if(cnt_ans[x] == 0)
                cnt_ans[x] = 1;
            else
                add_flag = true;
            seen.insert(x);
        }
        else if(seen2.count(x) == 0){
            auto stuff = factorize(x-1);
            map<int,int> cnt;
            for(int x : stuff)
                cnt[x]++;
            bool useful = false;
            for(auto _ : cnt)
                if(_.Y > cnt_ans[_.X]){
                    cnt_ans[_.X] = _.Y;
                    useful = true;
                }
            if(!useful)
                add_flag = true;
            seen2.insert(x);
        }
        else
            add_flag = 1;
    }
    for(auto _ : cnt_ans)
        for(int j = 0; j < _.Y; ++j)
            ans = (ans*_.X)%MOD;
    if(add_flag){
        ans = (ans+1)%MOD;
    }
    print(ans);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}

#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 2000007;
const int MOD = 1000000007;

int n;
int c[MAXN], un[MAXN];
bool isp[MAXN];

void init ();
void input ();
void work ();

int main()
{
	init();
	input();
	work();
}

void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d", &n );
	int x;
	lpi ( i, 1, n ){
		scanf ( "%d", &x );
		++c[x];
	}
}

void work ()
{
	// main work

	lp ( i, 1, MAXN ) if ( c[i] >= 2 ) ++c[i-1], --c[i];

	int ans = 1;
	int fc;
	INIT ( isp, true );
	fill ( un, un+MAXN, 1 );
	isp[0] = isp[1] = false;
	lp ( i, 2, MAXN ){
		if ( isp[i] ){
			if ( SC ( LL, i ) * i < MAXN ) for ( int j = i * i; j < MAXN; j += i ) isp[j] = false;
			for ( int t = i; t < MAXN; ( SC ( LL, t ) * t < MAXN ) ? ( t *= t ) : ( t = INF ) ){
				fc = 0;
				for ( int j = t; j < MAXN; j += t ){
					if ( c[j] ){
						++fc;
						if ( fc >= 2 ) break;
					}
				}
				if ( fc >= 2 ) for ( int j = t; j < MAXN; j += t ) if ( ( j / t ) % i ) un[j] *= t;
				if ( fc ) ans = SC ( LL, ans ) * i % MOD;
			}
		}
	}

	bool flag = false;
	lp ( i, 1, MAXN ){
		if ( c[i] >= 2 || ( c[i] && un[i] == i ) ){
			flag = true;
			break;
		}
	}
	if ( flag ) ++ans;

	cout << ans << endl;
}

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=2e6+10;
int n,a[N];
bool used[N];
long long ans;
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
void LCM(long long &a,int b){a*=(1ll*b/gcd(a,1ll*b));}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);used[a[n]]=1;ans=1ll*a[n];
	for(int i=n-1;i>=1;i--){
		while(used[a[i]]){if(a[i]==1)break;a[i]--;}
		used[a[i]]=1;
		LCM(ans,a[i]);
	}
	printf("%I64d\n",ans);
	return 0;
}

#include <iostream>
#include <vector>
using namespace std;
const int maxn = 2e6 + 100;
int n, x, H[maxn], F[maxn], M[maxn];
const int MOD = 1e9 + 7;
vector<int> V[maxn], T;
int main()
{
    long long ans = 1;
    for(int i = 2; i <= 2e6; i++){
        if(V[i].size() == 0)
            for(int j = 2; j*i <= 2e6; j++) V[i*j].push_back(i);
    }
    V[2].push_back(2);
    int f = 0, nt = 0;
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>x;
        H[x]++;
        if(H[x] == 1) {
            (ans *= x) %= MOD;
            M[x] = x;
            F[x]++;
            T.push_back(x);
        }
        else if(H[x] >= 2) {
            x--;
            T.push_back(x);
            for(auto o : V[x]){
                int temp = x, tot = 0;
                while(temp % o == 0) temp /= o, tot++;
                for(int i = H[o]+1; i <= tot; i++) (ans *= o) %= MOD;
                if(H[o] <= tot){
                    H[o] = max(H[o], tot);
                    F[M[o]]--;
                    M[o] = max(M[o], x);
                    F[M[o]]++;
                }
            }
        }
    }
    for(auto y : T) if(F[y] == 0) f = 1;
    cout<<ans + f<<endl;
    return 0;
}

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[200010];
bool v[2000010];
inline int gcd(int a,int b)
{
	if(a==0)return b;
	else return gcd(b%a,a);
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
   	int n=read(),ans=1;bool bk=true;
   	for(int i=1;i<=n;i++)
	{
		a[i]=read();int uf;
		if(v[a[i]]==false){uf=a[i];v[a[i]]=true;}
		else uf=a[i]-1;
		if(ans%uf==0)bk=false;
		else ans=ans/gcd(ans,uf)*uf;
	}pr2(ans);
    return 0;
}