Language: C++

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

int64_t EuclidMod(int64_t v, int64_t m){
  assert(v>=0);
  assert(m>0);
  // if(0 <= v && v < m){
  //   return v;
  // }else if(-m <= v && v < 0){
  //   return v + m;
  // }else{
  //   int64_t result = v % m;
  //   if(result < 0){
  //     result += m;
  //   }
  //   return result;
  // }
  return v%m;
}

int64_t ModInv(int64_t a, int64_t m){
  int64_t b = m, u = 1, v = 0;
  while(b){
    int64_t t = a / b;
    a -= t * b;
    std::swap(a, b);
    u -= t * v;
    std::swap(u, v);
  }
  EuclidMod(u, m);
  return u;
}

// return base^exponent (MOD. mod).
int64_t RepeatedPowMod(int64_t base, int64_t exponent, int64_t mod) {
  if (exponent == 0)
    return 1;
  else if (exponent % 2 == 0) {
    int64_t root = RepeatedPowMod(base, exponent / 2, mod);
    return (root * root) % mod;
  } else {
    return ((base%mod) * RepeatedPowMod(base, exponent - 1, mod)) % mod;
  }
}

template<int64_t mod>
class ModInt{
  int64_t value_;

public:
  explicit ModInt(const int64_t x = 0): value_(x % mod){
  };

  ModInt& operator=(const ModInt& another){
    value_=another.value_;
    return *this;
  }

  ModInt& operator^=(const ModInt& another){
    value_=RepeatedPowMod(value_,another.value_,mod);
    return *this;
  }

  ModInt& operator+=(const ModInt& another){
    value_ += another.value_;
    value_ = EuclidMod(value_, mod);
    return *this;
  }

  ModInt& operator-=(const ModInt& another){
    value_ -= another.value_;
    value_ = EuclidMod(value_, mod);
    return *this;
  }

  ModInt& operator*=(const ModInt& another){
    value_ *= another.value_;
    value_ = EuclidMod(value_, mod);
    return *this;
  }

  ModInt& operator/=(const ModInt& another){
    value_ = value_ * ModInv(another.value_, mod);
    value_ = EuclidMod(value_, mod);
    return *this;
  }

  ModInt& operator++(){
    value_ += 1;
    value_=EuclidMod(value_,mod);
    return *this;
  }

  ModInt operator++(int){
    ModInt tmp = *this;
    this->value_+=1;
    this->value_=EuclidMod(this->value_,mod);
    return tmp;
  }

  ModInt& operator--(){
    value_ -= 1;
    value_=EuclidMod(value_,mod);
    return *this;
  }

  ModInt operator--(int){
    ModInt tmp=*this;
    this->value_-=1;
    this->value_=EuclidMod(this->value_,mod);
    return tmp;
  }



  int64_t GetValue() const{
    return value_;
  }

};

template<int64_t mod>
ModInt<mod>
operator+(const ModInt<mod>& left, const ModInt<mod>& right){
  return ModInt<mod>(left) += right;
}

template<int64_t mod>
ModInt<mod>
operator-(const ModInt<mod>& left, const ModInt<mod>& right){
  return ModInt<mod>(left) -= right;
}

template<int64_t mod>
ModInt<mod>
operator/(const ModInt<mod>& left, const ModInt<mod>& right){
  return ModInt<mod>(left) /= right;
}

template<int64_t mod>
ModInt<mod>
operator*(const ModInt<mod>& left, const ModInt<mod>& right){
  return ModInt<mod>(left) *= right;
}

template<int64_t mod>
ModInt<mod>
operator^(const ModInt<mod>& left, const ModInt<mod>& right){
  return ModInt<mod>(left) ^= right;
}

template<int64_t mod>
std::ostream& operator<<(std::ostream& stream, const ModInt<mod>& mod_int){
  stream << mod_int.GetValue();
  return stream;
}



using std::cerr;
using std::cin;
using std::cout;
using std::endl;

const int64_t MOD=998244353;

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int64_t n;
  cin>>n;
  std::vector<int64_t> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  if(a[0]!=0){
    cout<<0<<endl;
    return 0;
  }
  int64_t max_a=0;

  std::vector<int64_t> count(n);
  for(auto v:a){
    count[v]++;
    max_a=std::max(max_a,v);
  }

  ModInt<MOD> result(1);
  for(int64_t i=1;i<=max_a;i++){
      if(count[i]==0){
        cout<<0<<endl;
        return 0;
      }
      result=ModInt<MOD>(result*RepeatedPowMod(count[i-1],count[i],MOD));
      assert(result.GetValue()>=0);

  }

  cout<<result.GetValue()%MOD<<endl;






  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:210:32: error: no match for 'operator*' (operand types are 'ModInt<998244353>' and 'int64_t' {aka 'long int'})
  210 |       result=ModInt<MOD>(result*RepeatedPowMod(count[i-1],count[i],MOD));
      |                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                          |                    |
      |                          ModInt<998244353>    int64_t {aka long int}
a.cc:156:1: note: candidate: 'template<long int mod> ModInt<mod> operator*(const ModInt<mod>&, const ModInt<mod>&)'
  156 | operator*(const ModInt<mod>& left, const ModInt<mod>& right){
      | ^~~~~~~~
a.cc:156:1: note:   template argument deduction/substitution failed:
a.cc:210:71: note:   mismatched types 'const ModInt<mod>' and 'int64_t' {aka 'long int'}
  210 |       result=ModInt<MOD>(result*RepeatedPowMod(count[i-1],count[i],MOD));
      |                                                                       ^