#include <bits/stdc++.h>
using ll = long long;
constexpr ll MOD = 998244353LL;
template <typename T>
constexpr T gcd(const T a, const T b) { return (b != 0) ? gcd(b, a % b) : a; }
int main()
{
    int N;
    std::cin >> N;
    std::vector<ll> a(N);
    for (int i = 0; i < N; i++) { std::cin >> a[i]; }
    std::sort(a.begin(), a.end());
    ll ans = 1;
    for (ll i = 0; i < N; i++) { (ans *= gcd(a[i], i)) %= MOD; }
    std::cout << ans << std::endl;
    return 0;
}
