#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}
int n, a[100005];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	int ans = 1;
	for (int i = 1; i <= n; i++)
		ans = 1ll * ans * gcd(a[i], i - 1) % mod;
	printf("%d\n", ans);
	return 0;
}