#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 998244353
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 A[101010];

i64 gcd(i64 a, i64 b)
{
	while (b > 0) {
		i64 tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}

i64 solve_fast()
{
	i64 ret = A[0];
	for (int i = 1; i < N; ++i) {
		i64 g = gcd(i, A[i]);
		i64 a = i / g, b = A[i] / g;
		ret = ret * g % MOD;
	}
	return ret;
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%lld", A + i);
	sort(A, A + N);
	/*

	vector<int> perm;
	for (int i = 0; i < N; ++i) perm.push_back(i);

	i64 B[12];
	for (int i = 1; i <= N; ++i) B[i] = 0;
	do {
		vector<bool> marked(N, false);
		i64 prod = 1;
		int cyc = 0;
		for (int i = 0; i < N; ++i) if (!marked[i]) {
			i64 mn = A[i];
			int p = i;
			while (!marked[p]) {
				marked[p] = true;
				mn = min(mn, A[p]);
				p = perm[p];
			}
			prod *= mn;
			++cyc;
		}
		B[cyc] += prod;
	} while (next_permutation(perm.begin(), perm.end()));

	for (int i = 1; i <= N; ++i) printf("%d: %lld\n", i, B[i]);
	i64 sol = B[1];
	for (int i = 2; i <= N; ++i) sol = gcd(sol, B[i]);
	printf("%lld\n", sol);
	*/
	printf("%lld\n", solve_fast());
	return 0;
}
