#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int mo = 998244353;
ll n,a[555555],b[55];
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
int main() {
	read(n);rep(i,1,n)read(a[i]);sort(a+1,a+n+1);
	ll tot=1;rep(i,1,n)tot=tot*gcd(a[i],i-1)%mo;cout<<tot;
	return 0;
	n=5;srand(time(0));
	while(1){
	a[0]=1;rep(i,1,n)a[i]=rand()%3+a[i-1];
	memset(b,0,sizeof(b));b[0]=1;
	rep(i,1,n){per(j,i,1)b[j]=(1LL*b[j-1]*a[i]+1LL*b[j]*(i-1));b[0]=0;}
	rep(i,1,n)printf("%d:%lld %lld\n",i,a[i],b[i]);
	ll res=0;rep(i,1,n)res=gcd(res,b[i]);printf("%lld\n",res);
	ll tot=1;rep(i,1,n)tot*=gcd(a[i],i-1);assert(res==tot);
	}
	return 0;
}
