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.
n=int(input())
listx=list(map(int,input().split()))
listx.sort()
count=0
x=1
if listx[0]==0:
  for i in range(1,n):
    if i==n-1:
      x*=count+1
    elif listx[i]==listx[i+1]:
      x*=count+2
      count=0
    else:
      count+=1
else:
  x=0
print(x)
#B
import sys
from collections import Counter
n=int(input())
d=list(map(int,input().split()))
e=Counter(d)
mod=998244353
if d[0]!=0 or e[0]!=1:
    print(0)
    sys.exit()
ans=1
for i in range(2,n):
    ans*=pow(e[i-1],e[i],mod)
    ans%=mod
print(ans%mod)