#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i=0; i<n; i++)

using LL = long long;
int N;
const LL MOD = 998244353;

LL gcd(LL a, LL b) {
  if (b ==  0) return a;
  return gcd(b, a%b);
}
 
int main() { 
  cin >> N;
  LL ans = 1;
  vector<int> as;
  rep(i, N) {
    int a;
    cin >> a;
    as.push_back(a);
  }
  sort(as.begin(), as.end());
  rep(i, N) {
    ans *= gcd(as[i], i);
     ans %= MOD;
  }
  cout << ans << endl;
}
