#include<bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 998244353;

int main() {
  int N, A[100000];
  cin >> N;

  for(int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);
  int64 ret = 1;
  for(int i = 0; i < N; i++) (ret *= __gcd(i + 1, A[i])) %= mod;
  cout << ret << endl;
}
