#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
map<int, int> primes;
map<int, int> prime_to_index;
vector<pair<int, int> > max_prime_powers;
vector<int> p;
set<int> necessary;
inline int A(long long a) { return a % mod; }
bool Is_new_look_at_primes(int a) {
  if (a == 1) return false;
  if (a % 2 == 1) {
    int b = prime_to_index[a];
    if (max_prime_powers[b].first == 0) {
      max_prime_powers[b].first = 1;
      return true;
    }
    return false;
  }
  bool answer = false;
  for (int i = 0; i < p.size(); i++) {
    int current = 0;
    while (a % p[i] == 0) {
      current++;
      a /= p[i];
    }
    if (current > max_prime_powers[i].first) answer = true;
    max_prime_powers[i].first = max(max_prime_powers[i].first, current);
    if (a == 1) break;
    if (a < (long long)p[i] * p[i]) {
      int b = prime_to_index[a];
      if (max_prime_powers[b].first == 0) {
        max_prime_powers[b].first = 1;
        answer = true;
      }
      break;
    }
  }
  return answer;
}
void Fill_second(int a) {
  if (a == 1) return;
  if (a % 2 == 1) {
    int b = prime_to_index[a];
    if (max_prime_powers[b].first == 1) max_prime_powers[b].second++;
    return;
  }
  for (int i = 0; i < p.size(); i++) {
    int current = 0;
    while (a % p[i] == 0) {
      current++;
      a /= p[i];
    }
    if (current == max_prime_powers[i].first) max_prime_powers[i].second++;
    if (a == 1) return;
    if (a < (long long)p[i] * p[i]) {
      int b = prime_to_index[a];
      if (max_prime_powers[b].first == 1) max_prime_powers[b].second++;
      return;
    }
  }
}
bool Can_not_be_used(int a) {
  if (a == 1) return true;
  if (a % 2 == 1) {
    int b = prime_to_index[a];
    return 2 < max_prime_powers[b].first + max_prime_powers[b].second;
  }
  for (int i = 0; i < p.size(); i++) {
    int current = 0;
    while (a % p[i] == 0) {
      current++;
      a /= p[i];
    }
    if (current >= max_prime_powers[i].first + max_prime_powers[i].second - 1)
      return false;
    if (a == 1) break;
    if (a < (long long)p[i] * p[i]) {
      int b = prime_to_index[a];
      if (2 >= max_prime_powers[b].first + max_prime_powers[b].second)
        return false;
      break;
    }
  }
  return true;
}
void Fill_p() {
  const int max_p = 2000000;
  vector<bool> is_prime(max_p, true);
  for (int i = 2; i < max_p; i++) {
    if (is_prime[i]) {
      p.push_back(i);
      prime_to_index[i] = p.size() - 1;
      max_prime_powers.push_back(make_pair(0, 0));
      for (long long j = (long long)i * i; j < max_p; j += i)
        is_prime[j] = false;
    }
  }
}
int Pow(int a, int n) {
  if (n == 0) return 1;
  if (n % 2 == 0) return Pow(A((long long)a * a), n / 2);
  return A((long long)Pow(A((long long)a * a), n / 2) * a);
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  Fill_p();
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (primes.find(a) == primes.end())
      primes[a] = 1;
    else
      primes[a]++;
  }
  bool is_plus1_used = false;
  vector<int> used_values;
  for (map<int, int>::reverse_iterator it = primes.rbegin(),
                                       it_end = primes.rend();
       it != it_end; ++it) {
    if (it->second == 1) {
      if (Is_new_look_at_primes(it->first))
        used_values.push_back(it->first);
      else {
        Is_new_look_at_primes(it->first - 1);
        used_values.push_back(it->first - 1);
      }
    } else {
      Is_new_look_at_primes(it->first);
      Is_new_look_at_primes(it->first - 1);
      used_values.push_back(it->first);
      used_values.push_back(it->first - 1);
      if (it->second >= 3) is_plus1_used = true;
    }
  }
  if (is_plus1_used) {
    long long answer = 1;
    for (int i = 0; i < p.size(); i++)
      answer = A(answer * Pow(p[i], max_prime_powers[i].first));
    answer = A(answer + 1);
    cout << answer << endl;
    return 0;
  }
  for (int i = 0; i < used_values.size(); i++) Fill_second(used_values[i]);
  for (int i = 0; i < used_values.size(); i++)
    if (Can_not_be_used(used_values[i])) {
      is_plus1_used = true;
      break;
    }
  long long answer = 1;
  for (int i = 0; i < p.size(); i++)
    answer = A(answer * Pow(p[i], max_prime_powers[i].first));
  if (is_plus1_used) answer = A(answer + 1);
  cout << answer << endl;
}
