Problem: You are given a tuple generator f^{(k)} = (f_1^{(k)}, f_2^{(k)}, ..., f_n^{(k)}), where f_i^{(k)} = (a_i ⋅ f_i^{(k - 1)} + b_i) mod p_i and f^{(0)} = (x_1, x_2, ..., x_n). Here x mod 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 ≥ 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

Input

The first line contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in the tuple.

The second line contains n space separated prime numbers — the modules p_1, p_2, …, p_n (2 ≤ p_i ≤ 2 ⋅ 10^6).

Output

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

Examples

Input

4
2 3 5 7


Output

210


Input

3
5 3 3


Output

30

Note

In the first example we can choose next parameters: a = [1, 1, 1, 1], b = [1, 1, 1, 1], x = [0, 0, 0, 0], then f_i^{(k)} = k mod p_i.

In the second example we can choose next parameters: a = [1, 1, 2], b = [1, 1, 0], x = [0, 0, 1].

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 200000;
const int MAXVAL = 2000000;
const int MOD = 1000000007;
int n;
int a[MAXN];
int b[MAXN];
int c[MAXN], nc;
int pmn[MAXVAL + 1];
int cnt[MAXVAL + 1];
int times[MAXVAL + 1];
void mark(int x) {
  while (x != 1) {
    int p = pmn[x], cur = 0;
    while (x % p == 0) ++cur, x /= p;
    if (cur > cnt[p]) cnt[p] = cur, times[p] = 0;
    if (cur == cnt[p]) ++times[p];
  }
}
bool isneeded(int x) {
  while (x != 1) {
    int p = pmn[x], cur = 0;
    while (x % p == 0) ++cur, x /= p;
    if (cur == cnt[p] && times[p] == 1) return true;
  }
  return false;
}
int solve() {
  memset(pmn, -1, sizeof(pmn));
  for (int i = (2); i <= (MAXVAL); ++i)
    if (pmn[i] == -1)
      for (int j = i; j <= MAXVAL; j += i)
        if (pmn[j] == -1) pmn[j] = i;
  for (int i = (0); i < (n); ++i) b[i] = a[i];
  sort(b, b + n);
  reverse(b, b + n);
  memset(cnt, 0, sizeof(cnt));
  memset(times, 0, sizeof(times));
  nc = 0;
  bool extra = false;
  for (int l = 0, r = l; l < n; l = r) {
    while (r < n && b[l] == b[r]) ++r;
    int p = b[l], cur = r - l;
    if (cnt[p] == 0) {
      if (cur >= 1) mark(p), c[nc++] = p;
      if (cur >= 2) mark(p - 1), c[nc++] = p - 1;
      if (cur >= 3) extra = true;
    } else {
      if (cur >= 1) mark(p - 1), c[nc++] = p - 1;
      if (cur >= 2) extra = true;
    }
  }
  for (int i = (0); i < (nc); ++i)
    if (!isneeded(c[i])) extra = true;
  int ret = 1;
  for (int i = (2); i <= (MAXVAL); ++i)
    for (int j = (0); j < (cnt[i]); ++j) ret = (long long)ret * i % MOD;
  if (extra) ret = (ret + 1) % MOD;
  return ret;
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  printf("%d\n", solve());
}
void research1() {
  vector<bool> isp(1001, true);
  isp[0] = isp[1] = false;
  for (int i = (0); i < (((int)(isp).size())); ++i)
    if (isp[i])
      for (int j = i + i; j < ((int)(isp).size()); j += i) isp[j] = false;
  for (int i = (0); i < (((int)(isp).size())); ++i)
    if (isp[i]) {
      int p = i;
      set<pair<int, int>> can;
      for (int a = (0); a < (p); ++a)
        for (int b = (0); b < (p); ++b)
          for (int c = (0); c < (p); ++c) {
            vector<int> seen(p, -1);
            int t = 0, x = c;
            while (seen[x] == -1) {
              seen[x] = t;
              x = ((long long)x * a + b) % p;
              ++t;
            }
            can.insert(make_pair(t - seen[x], seen[x]));
          }
      printf("%d:", p);
      for (auto it = can.begin(); it != can.end(); ++it) {
        int per = it->first, lead = it->second;
        if (lead == 0 && (per == p || (p - 1) % per == 0)) continue;
        if (lead == 1 && per == 1) continue;
        printf(" %d", per);
        if (lead != 0) printf("[%d]", lead);
      }
      puts("");
    }
}
void research2() {
  int p1 = 3, p2 = 2, p3 = 2;
  set<int> can;
  for (int a1 = (0); a1 < (p1); ++a1)
    for (int b1 = (0); b1 < (p1); ++b1)
      for (int c1 = (0); c1 < (p1); ++c1)
        for (int a2 = (0); a2 < (p2); ++a2)
          for (int b2 = (0); b2 < (p2); ++b2)
            for (int c2 = (0); c2 < (p2); ++c2)
              for (int a3 = (0); a3 < (p3); ++a3)
                for (int b3 = (0); b3 < (p3); ++b3)
                  for (int c3 = (0); c3 < (p3); ++c3) {
                    vector<int> cur(3);
                    cur[0] = c1, cur[1] = c2, cur[2] = c3;
                    set<vector<int>> seen;
                    int nseen = 0;
                    while (!seen.count(cur)) {
                      seen.insert(cur);
                      ++nseen;
                      cur[0] = ((long long)cur[0] * a1 + b1) % p1;
                      cur[1] = ((long long)cur[1] * a2 + b2) % p2;
                      cur[2] = ((long long)cur[2] * a3 + b3) % p3;
                    }
                    if (!can.count(nseen)) {
                      can.insert(nseen);
                      printf("%d (%d,%d,%d) (%d,%d,%d) (%d,%d,%d)\n", nseen, a1,
                             b1, c1, a2, b2, c2, a3, b3, c3);
                    }
                  }
}
int main() {
  run();
  return 0;
}