#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n;
int ans;
int a[100005];
int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
int main() {
  scanf("%d", &n);
  ans = 1;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) ans = 1ll * ans * gcd(a[i], i) % mod;
  printf("%d\n", ans);
}
