#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int mo=998244353;
int n,ans=1,a[100000+10];
int gcd(int x,int y) {
    if (y==0) return x;
    return gcd(y,x%y);
}
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=(long long)ans*gcd(i-1,a[i])%998244353;
    printf("%d\n",ans);
    return 0;
}
