#include <bits/stdc++.h>
using namespace std;
template <class T>
using vv = vector<vector<T>>;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &t) {
  os << "{";
  for (int(i) = 0; (i) < (t.size()); ++(i)) {
    os << t[i] << ",";
  }
  os << "}" << endl;
  return os;
}
template <class T, size_t n>
ostream &operator<<(ostream &os, const array<T, n> &t) {
  os << "{";
  for (int(i) = 0; (i) < (n); ++(i)) {
    os << t[i] << ",";
  }
  os << "}" << endl;
  return os;
}
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &t) {
  return os << "(" << t.first << "," << t.second << ")";
}
template <class S, class T, class U>
ostream &operator<<(ostream &os, const tuple<S, T, U> &t) {
  return os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
}
template <class S, class T, class U, class V>
ostream &operator<<(ostream &os, const tuple<S, T, U, V> &t) {
  return os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ","
            << get<3>(t) << ")";
}
template <class S, class T, class U, class V, class W>
ostream &operator<<(ostream &os, const tuple<S, T, U, V, W> &t) {
  return os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ","
            << get<3>(t) << "," << get<4>(t) << ")";
}
template <class T>
inline bool MX(T &l, const T &r) {
  return l < r ? l = r, 1 : 0;
}
template <class T>
inline bool MN(T &l, const T &r) {
  return l > r ? l = r, 1 : 0;
}
const long long MOD = 998244353;
long long modpow(long long r, long long n, long long m = MOD) {
  long long re = 1, d = r % m;
  if (n < 0) (n %= m - 1) += m - 1;
  for (; n; n /= 2) {
    if (n & 1) (re *= d) %= m;
    (d *= d) %= m;
  }
  return re;
}
template <int mod = MOD>
struct modInt {
  int v;
  modInt(int v = 0) : v(v) {}
  modInt operator+(const modInt &n) const {
    return v + n.v < mod ? v + n.v : v + n.v - mod;
  }
  modInt operator-(const modInt &n) const {
    return v - n.v < 0 ? v - n.v + mod : v - n.v;
  }
  modInt operator*(const modInt &n) const { return long long(v) * n.v % mod; }
  modInt operator/(const modInt &n) const {
    return long long(v) * modpow(n.v % mod, -1, mod) % mod;
  }
  modInt operator+(const long long &n) const {
    return v + n < mod ? v + n : v + n - mod;
  }
  modInt operator-(const long long &n) const {
    return v - n < 0 ? v - n + mod : v - n;
  }
  modInt operator*(const long long &n) const {
    return long long(v) * (n % mod) % mod;
  }
  modInt operator/(const long long &n) const {
    return long long(v) * modpow(n % mod, -1, mod) % mod;
  }
  modInt &operator+=(const modInt &n) {
    v += n.v;
    if (v >= mod) v -= mod;
    return *this;
  }
  modInt &operator-=(const modInt &n) {
    v -= n.v;
    if (v < 0) v += mod;
    return *this;
  }
  modInt &operator*=(const modInt &n) {
    v = long long(v) * n.v % mod;
    return *this;
  }
  modInt &operator/=(const modInt &n) {
    v = long long(v) * modpow(n.v, -1, mod) % mod;
    return *this;
  }
  modInt &operator+=(const long long &n) {
    v += n;
    if (v >= mod) v -= mod;
    return *this;
  }
  modInt &operator-=(const long long &n) {
    v -= n;
    if (v < 0) v += mod;
    return *this;
  }
  modInt &operator*=(const long long &n) {
    v = long long(v) * n % mod;
    return *this;
  }
  modInt &operator/=(const long long &n) {
    v = long long(v) * modpow(n, -1, mod) % mod;
    return *this;
  }
};
template <int mod>
ostream &operator<<(ostream &os, const modInt<mod> &n) {
  return os << n.v;
};
template <int mod>
modInt<mod> operator+(const long long &n, const modInt<mod> &m) {
  return m.v + n < mod ? m.v + n : m.v + n - mod;
}
template <int mod>
modInt<mod> operator-(const long long &n, const modInt<mod> &m) {
  return n - m.v < 0 ? n - m.v + mod : n - m.v;
}
template <int mod>
modInt<mod> operator*(const long long &n, const modInt<mod> &m) {
  return long long(m.v) * (n % mod) % mod;
}
template <int mod>
modInt<mod> operator/(const long long &n, const modInt<mod> &m) {
  return long long(m.v) * modpow(n % mod, -1, mod) % mod;
}
template <int mod>
modInt<mod> modpow(modInt<mod> r, long long n) {
  modInt<mod> re(1);
  if (n < 0) (n %= mod - 1) += mod - 1;
  for (; n; n /= 2) {
    if (n & 1) re *= r;
    r *= r;
  }
  return re;
}
vector<modInt<MOD>> fact, finv, inv;
modInt<MOD> comb(long long n, long long r) {
  if (n < r || r < 0) return 0;
  return fact[n] * finv[n - r] * finv[r];
}
class Doralion {
  void Modinvs(vector<modInt<MOD>> &re, int n) {
    re.resize(n + 1);
    re[1] = 1;
    for (int i = 2; i <= n; ++i) re[i] = re[MOD % i] * (MOD - MOD / i);
  }
  void Facts(vector<modInt<MOD>> &re, int n) {
    re.resize(n + 1);
    re[0] = 1;
    for (int(i) = 0; (i) < (n); ++(i)) re[i + 1] = re[i] * (i + 1);
  }
  void Factinvs(vector<modInt<MOD>> &re, const vector<modInt<MOD>> &inv,
                int n) {
    re.resize(n + 1);
    re[0] = 1;
    for (int(i) = 0; (i) < (n); ++(i)) re[i + 1] = re[i] * inv[i + 1];
  }

 public:
  Doralion(int n) {
    Modinvs(inv, n);
    Facts(fact, n);
    Factinvs(finv, inv, n);
  }
} doralion(212345);
int main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int(i) = 0; (i) < (n); ++(i)) cin >> a[i];
  int mn = *min_element((a).begin(), (a).end());
  int cnt = 0;
  for (int x : a)
    if (x == mn) ++cnt;
  if (cnt < n) {
    cout << mn << endl;
    return 0;
  }
  int t = 1;
  for (long long i = mn; i < n; i *= mn) t += (n - 1) / i;
  (mn, cnt, t, 1);
  cout << modpow(mn, min(cnt, t)) << endl;
  return 0;
}
