#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define MOD 998244353

ll N;
vector<ll> A;

ll ans;
ll i,j;

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

int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        ll a;
        scanf("%lld", &a);
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    ans = 1;
    fornum(i,0,N){
        ans = (ans * gcd(A[i], i))%MOD;
    }
    printf("%lld", ans);

    return 0;
}