#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define P 998244353
#define M 200010

using namespace std;

typedef long long ll;

int n, A[M];

ll gcd(ll x, ll y) {return !y ? x : 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);
    ll ans = 1;
    for(int i = 1; i <= n; i++) ans = ans * gcd(A[i], i - 1) % P;
    printf("%lld\n", ans);
    return 0;
}