#include<bits/stdc++.h>
using namespace std;
const int md=998244353;
int mygcd(int x,int y){return !y?x:mygcd(y,x%y);};
int n;
int a[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	sort(a+1,a+n+1);
	int ans=1;
	for(int i=1;i<=n;i++)ans=1LL*ans*mygcd(a[i],i-1)%md;
	printf("%d",ans);
	return 0;
}