#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const int mod=998244353;
int gcd(int a,int b) {return a==0?b:gcd(b%a,a);}
int n,ans=1,a[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) ans=(LL)ans*gcd(a[i],i-1)%mod;
	printf("%d",ans);
}