#include <bits/stdc++.h>
using namespace std;

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

const int MOD = 998244353;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int dfs(int i, vector<int>& p, vector<int>& a, vector<bool>& vis) {
    if (vis[i]) return INT_MAX;
    vis[i] = true;
    return min(a[i], dfs(p[i], p, a, vis));
}

int main() {
    int N; cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    ll ans = 1;
    rep(i, N) ans = ans * gcd(i, a[i]) % MOD;
    cout << ans << endl;
    return 0;
    for (;;) {
        int N; cin >> N;
        vector<int> a(N);
        rep(i, N) cin >> a[i];
        vector<int> p(N);
        iota(all(p), 0);
        vector<ll> ans(N + 1);
        do {
            vector<bool> vis(N);
            int k = 0;
            ll x = 1;
            rep(i, N) if (!vis[i]) {
                k++;
                x *= dfs(i, p, a, vis);
            }
            ans[k] += x;
        } while (next_permutation(all(p)));
        rep(k, N + 1) cout << ans[k] << ' ';
        cout << endl;
        ll d = 0;
        rep(k, N + 1) d = gcd(d, ans[k]);
        cout << d << endl;
    }
}
