output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      D_1 D_2 ... D_N
attempt: from copy import deepcopy
  from sys import exit, setrecursionlimit
  import math
  from collections import defaultdict, Counter, deque
  from fractions import Fraction as frac
  import bisect
  import sys
  
  input = sys.stdin.readline
  
  setrecursionlimit(1000000)
  
  
  def main():
      n = int(input())
      d = list(map(int, input().split()))
      z = defaultdict(int)
      for i in d:
          z[i] += 1
      mx = max(d)
      for i in range(mx + 1):
          if z[i] == 0:
              print(0)
              return
      if d[0] != 0 and z[0] != 1:
          print(0)
          return
      ans = 1
      for i in reversed(range(1, mx + 1)):
          ans *= z[i - 1] ** z[i]
      print(ans % 998244353)
  
  
  def factorization(n):
      arr = []
      temp = n
      for i in range(2, int(-(-(n**0.5) // 1)) + 1):
          if temp % i == 0:
              cnt = 0
              while temp % i == 0:
                  cnt += 1
                  temp //= i
              arr.append([i, cnt])
  
      if temp != 1:
          arr.append([temp, 1])
  
      if arr == []:
          arr.append([n, 1])
  
      return arr
  
  
  def zip(a):
      mae = a[0]
      ziparray = [mae]
      for i in range(1, len(a)):
          if mae != a[i]:
              ziparray.append(a[i])
              mae = a[i]
      return ziparray
  
  
  def is_prime(n):
      if n < 2:
          return False
  
      for k in range(2, int(math.sqrt(n)) + 1):
          if n % k == 0:
              return False
  
      return True
  
  
  def list_replace(n, f, t):
      return [t if i == f else i for i in n]
  
  
  def base_10_to_n(X, n):
      X_dumy = X
      out = ""
      while X_dumy > 0:
          out = str(X_dumy % n) + out
          X_dumy = int(X_dumy / n)
      if out == "":
          return "0"
      return out
  
  
  def gcd(l):
      x = l.pop()
      y = l.pop()
      while x % y != 0:
          z = x % y
          x = y
          y = z
      l.append(min(x, y))
      return gcd(l) if len(l) > 1 else l[0]
  
  
  class Queue:
      def __init__(self):
          self.q = deque([])
  
      def push(self, i):
          self.q.append(i)
  
      def pop(self):
          return self.q.popleft()
  
      def size(self):
          return len(self.q)
  
      def debug(self):
          return self.q
  
  
  class Stack:
      def __init__(self):
          self.q = []
  
      def push(self, i):
          self.q.append(i)
  
      def pop(self):
          return self.q.pop()
  
      def size(self):
          return len(self.q)
  
      def debug(self):
          return self.q
  
  
  class graph:
      def __init__(self):
          self.graph = defaultdict(list)
  
      def addnode(self, l):
          f, t = l[0], l[1]
          self.graph[f].append(t)
          self.graph[t].append(f)
  
      def rmnode(self, l):
          f, t = l[0], l[1]
          self.graph[f].remove(t)
          self.graph[t].remove(f)
  
      def linked(self, f):
          return self.graph[f]
  
  
  class dgraph:
      def __init__(self):
          self.graph = defaultdict(set)
  
      def addnode(self, l):
          f, t = l[0], l[1]
          self.graph[f].append(t)
  
      def rmnode(self, l):
          f, t = l[0], l[1]
          self.graph[f].remove(t)
  
      def linked(self, f):
          return self.graph[f]
  
  
  main()
  
problem_description: Statement
  
  Given is an integer sequence D_1,...,D_N of N elements. Find the number,
  modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the
  following condition:
  
    * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
samples: [{"input": "4\n    0 1 1 2", "output": "2\n    \n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the\ncondition.\n\n* * *"}, {"input": "4\n    1 1 1 1", "output": "0\n    \n\n* * *"}, {"input": "7\n    0 3 2 1 2 2 1", "output": "24"}]