#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 998244353;

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

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

    ll t = a[0];
    for (int i = 1; i < n; i++) {
        (t*=gcd(a[i], (ll)i))%=MOD;
    }
    cout<<t<<endl;

    return 0;
}