#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#define SZ(x) ((int) (x).size())
using namespace std;

int gcd(int a, int b) {
    while (b) {
        int c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    #ifdef LOCAL_RUN
    freopen("E.in", "r", stdin);
    freopen("E.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<int> a(n);
    for (int& x: a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    const int MOD = 998244353;
    int ans = a[0] % MOD;
    for (int i = 1; i < n; ++i) {
        ans = ans * (int64_t) gcd(a[i], i) % MOD;
    }
    cout << ans << '\n';
}
