#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, N) for(int i = 0; i < int(N); i++)
#define rep1(i, N) for (int i = 1; i <= int(N); i++)
#define fs first
#define sc second
#define pb push_back
#define PB push_back
#define MP make_pair
#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

template <uint MD> struct ModInt {
    using M = ModInt;
    uint v;
    ModInt() : v{0} {}
    ModInt(ll _v) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M(0) - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return (*this).pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<998244353>;

int main() {
    int n;
    cin >> n;
    V<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());


    // naive solution
/*    V<ll> sm(n+1);
    V<int> idx(n);
    iota(idx.begin(), idx.end(), 0);

    do {
        V<bool> used(n);
        ll buf = 1; int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (used[i]) continue;
            cnt++;
            int p = i;
            ll mi = TEN(18);
            do {
                mi = min(mi, a[p]);
                used[p] = true;
                p = idx[p];
            } while (p != i);
            buf *= mi;
        }
        sm[cnt] += buf;
    } while (next_permutation(idx.begin(), idx.end()));

    for (auto d: sm) cout << d << ", ";
    cout << endl;

    ll ans = 0;
    for (auto d: sm) ans = gcd(ans, d);
    cout << ans << endl;*/

    Mint ans = 1;
    for (int i = 0; i < n; i++) {
        ans *= gcd(i, a[i]);
    }
    cout << ans.v << endl;
    return 0;
}