#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define rep0(i,r) for (int i=0,i##end=r;i<i##end;++i)
#define ll long long
using namespace std;
const int N=1e6+6,P=998244353;
int a[N];
int gcd(int x,int y){ return y==0?x:gcd(y,x%y); }
int main(){
	int n,ans=1; scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	rep(i,1,n) ans=(ll)ans*gcd(i-1,a[i])%P;
	cout<<ans<<endl;
	return 0;
}