#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define pb push_back
#define fi first
#define se second

#define Mod 998244353
 
ll gcd(ll a,ll b){
    if(a>b) swap(a,b);
    if(b%a==0) return a;
    else return gcd(a,b%a);
}

int main(){
    int i,j;
    int n;

    cin>>n;
    ll a[n];

    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll mi=a[0];

    for(i=2;i<n;i++){
        mi*=gcd(a[i],i);
        mi%=Mod;
    }

    cout<<mi<<endl;
    return 0;
}