#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MOD = 998244353;

long long GCD(long long x, long long y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main() {
    int N;
    cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    long long res = 1;
    for (int i = 0; i < N; ++i) {
        res = (res * GCD(a[i], i)) % MOD;
    }
    cout << res << endl;
}
