Language: C++

  #include <iostream>
  #include <vector>
  #include <set>
  #include <map>
  #include <cmath>

  #pragma GCC optimize ("-O3")
  #define rep(i, initial_value, max_value) for (int i{initial_value}; i < max_value; ++i)
  #define fore(i, a) for(auto &i:a)
  #define each(i, c) \
    for( \
        __typeof((c).begin()) i{(c).begin()}, __typeof((c).end()) end{(c).end()}; \
        i != end; \
        ++i \
    )
  #define dbg(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
  #define all(x) (x).begin(),(x).end()

  using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
  typedef long long ll; typedef unsigned long long ull; typedef unsigned __int128 u128; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
  template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
  template<class T>bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }

  // ===

  ull a[100000];

  void _main() {
    ull n;
    cin >> n;
    rep(i, 0, n) cin >> a[i];

    u128 ans{1};

    std::map<ull, ull> m;
    ull max{0};

    rep(i, 0, n) {
      ull num = a[i];
      chmax(max, num);

      if (m.find(num) == m.end()) {
        m[num] = 1;
      } else {
        m[num] += 1;
      }
    }

    if (m[0] != 1) {
      cout << 0 << endl;
      return;
    }

    ull prevCount{1};

    rep(i, 1, max + 1) {
      if (m.find(i) == m.end()) {
        cout << 0 << endl;
        return;
      }

      ans *= pow(prevCount, m[i]);
      prevCount = m[i];
    }

    cout << ans % 998244353 << endl;
  }

Compiler output:
a.cc:20:109: error: 'INT_MAX' was not declared in this scope
   20 |   typedef long long ll; typedef unsigned long long ull; typedef unsigned __int128 u128; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
      |                                                                                                             ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 |   #include <cmath>
  +++ |+#include <climits>
    6 | 
a.cc: In function 'void _main()':
a.cc:66:10: error: ambiguous overload for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'u128' {aka '__int128 unsigned'})
   66 |     cout << ans % 998244353 << endl;
      |     ~~~~ ^~ ~~~~~~~~~~~~~~~
      |     |           |
      |     |           u128 {aka __int128 unsigned}
      |     std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  174 |       operator<<(long __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  178 |       operator<<(unsigned long __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  182 |       operator<<(bool __n)
      |       ^~~~~~~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
   96 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  189 |       operator<<(unsigned short __n)
      |       ^~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
  110 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  200 |       operator<<(unsigned int __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  211 |       operator<<(long long __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  215 |       operator<<(unsigned long long __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  231 |       operator<<(double __f)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  235 |       operator<<(float __f)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  243 |       operator<<(long double __f)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:573:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char) [with _CharT = char; _Traits = char_traits<char>]'
  573 |     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
      |     ^~~~~~~~
/usr/include/c++/14/ostream:579:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char) [with _Traits = char_traits<char>]'
  579 |     operator<<(basic_ostream<char, _Traits>& __out, char __c)
      |     ^~~~~~~~
/usr/include/c++/14/ostream:590:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char) [with _Traits = char_traits<char>]'
  590 |     operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
      |     ^~~~~~~~
/usr/include/c++/14/ostream:595:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char) [with _Traits = char_traits<char>]'
  595 |     operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
      |     ^~~~~~~~