#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int mo=998244353;
const int N=1e6;
int n,ans,a[N+10];
bool p[N+10];
int main() {
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    ans=a[1]%mo;
    a[1]=1;
    memset(p,1,sizeof(p));
    p[1]=0;
    for (int i=2;i<n;i++) {
        if (!p[i]) continue;
        for (int j=i*2;j<n;j+=i) p[j]=0;
        for (int j=i;j<n;j+=i) {
            int x=j,y=a[j+1];
            while (x%i==0&&y%i==0) {
                x/=i;
                y/=i;
                ans=(long long)ans*i%mo;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}
