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 std::lower_bound;
using std::max;
using std::min;
using std::random_shuffle;
using std::reverse;
using std::sort;
using std::swap;
using std::unique;
using std::upper_bound;
using std::vector;
void open(const char *s) {}
void open2(const char *s) {}
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 long long 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;
    }
  }
}
std::pair<int, int> d[N];
std::pair<int, int> s1[N], s2[N];
int n, t;
int bb[N];
int main() {
  open("d");
  scanf("%d", &n);
  int flag = 0;
  init();
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1, std::greater<int>());
  for (int i = 1; i <= n; i++) {
    if (s[a[i]] == 0) {
      s[a[i]]++;
      if (a[i] == 2) s[a[i]]++;
      bb[i] = 2;
      if (!s1[a[i]].first) {
        if (std::pair<int, int>(a[i], i) > s1[a[i]]) {
          s2[a[i]] = s1[a[i]];
          s1[a[i]] = std::pair<int, int>(a[i], i);
        } else
          s2[a[i]] = max(s2[a[i]], std::pair<int, int>(a[i], i));
        continue;
      }
    }
    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] = std::pair<int, int>(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] = std::pair<int, int>(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;
        if (s1[v].second == i) {
          if (s2[v].first == s1[v].first)
            ;
          else
            ff = 0;
        }
      }
      if (ff) {
        flag = 1;
        break;
      }
    }
  long long 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;
}