#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

const ll mod = 998244353;
ll modpow(ll n,ll r){
  ll res = 1;
  while(r){
    if(r & 1)res = res*n%mod;
    n = n*n%mod;
    r >>= 1;
  }
  return res;
}

int main(){

  int  n;
  cin >> n;
  vector<int> v(n,0);
  bool is = true;
  rep(i,n){
    int x;cin >> x;
    v[x]++;
    if(i == 0 && x != 0)is =false;
  }
  int mx = 0;
  rep(i,n)if(v[i] != 0)mx = i;
  ll res = 1;
  for(int i = 1;i <= mx;i++)(res *= modpow(v[i-1],v[i]))%=mod;
  if(v[0] != 1 || !is)res = 0;
  cout << res << endl;




  return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int N;
  cin >> N;
  
  vector<int> L(N);
  for(int i = 0; i < N; i++) cin >> L.at(i);
  
  int total = 0;
  
  if(N < 3) cout << "0" << endl;
  else
  {
    for(int i = 0; i < N - 2; i++)
    {
      for(int j = i + 1; j < N - 1; j++)
      {
        for(int k = j + 1; k < N; k++)
        {
          if(L.at(i) == L.at(j) || L.at(j) == L.at(k) || L.at(k) == L.at(i))
          {
            continue;
          }
          if(L.at(i) + L.at(j) > L.at(k) && L.at(i) + L.at(k) > L.at(j) && L.at(j) + L.at(k) > L.at(i))
          {
            total++;
          }
        }
      }
    }
    cout << total << endl;
  }
}