#include <bits/stdc++.h>

using namespace std;

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

typedef pair<int, int> ii;

const int N = 1e5 + 5;

int n, a[N], mul = 1;

const int mod = 1e9 + 7;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    for(int i = 0; i < n; i++)
        mul = (1ll * mul * __gcd(i, a[i + 1])) % mod;
    cout << mul;
}
