//Δ_E
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 111111;
const int MO = 998244353;
int gcd(int x,int y){
	if(!y)
		return x;
	return gcd(y,x%y);
}
int n,a[N];
int main()
{
	int i,x;
	scanf("%d",&n);
	for(i=0;i<n;i=i+1)
		scanf("%d",a+i);
	sort(a,a+n);
	x=1;
	for(i=0;i<n;i=i+1)
		x=(LL)x*gcd(a[i],i)%MO;
	cout<<x;
	return 0;
}