import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto d = readln.chomp.split.to!(int[]);
  immutable mod = 998244353;

  int[int] cnt;
  foreach (i; 0..n) {
    cnt[d[i]]++;
  }

  if (d[0] != 0 || cnt.get(0, 0) != 1) {
    writeln(0);
    return;
  }

  if (n == 1) {
    writeln(1);
    return;
  }

  long res = 1;
  auto m = cnt.keys.reduce!(max);
  auto pat = new long[](m+1);
  pat[0..2] = 1;
  foreach (i; 2..m+1) {
    auto num = cnt.get(i, 0);
    long tmp = cnt.get(i-1, 0);
    foreach (_; 1..num) {
      tmp = (tmp * cnt.get(i-1, 0)) % mod;
    }
    pat[i] = (pat[i-1] * tmp) % mod;
  }

  pat[$-1].writeln;
}
