#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int d[101010];
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  if (b == 0) return a;
  for (;;) {
    if (a < b) swap(a, b);
    a %= b;
    if (a == 0) return b;
  }
}
int main() {
  int num;
  scanf("%d", &num);
  for (int i = 0; i < num; i++) scanf("%d", &d[i]);
  sort(d, d + num);
  long long m = 1;
  for (int i = 0; i < num; i++) m = m * gcd(d[i], i) % mod;
  printf("%lld\n", m);
}
