#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long INF = mod * mod;
const double eps = 1e-8;
const double pi = acos(-1.0);
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  while (b) {
    int r = a % b;
    a = b;
    b = r;
  }
  return a;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    long long g = gcd(i, a[i - 1]);
    ans = ans * g % mod;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
