#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int mod=998244353;
int n,a[100001],ans;

int gcd(int a,int b) {return (!b)?a:gcd(b,a%b);} 

int main()
{
	scanf("%d",&n); ans=1;
	for (int i=1; i<=n; i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for (int i=1; i<=n; i++) ans=1ll*ans*gcd(i-1,a[i])%mod;
	printf("%d\n",ans);
	return 0;
}