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.
from collections import Counter

N = int(input())
D = list(map(int,input().split()))
C = Counter(D)
mod = 998244353
ans = 1
D_max = max(D)

if D[0] != 0 or C[0] != 1:
    print(0)
    exit()

def make_factorial_table(n):
    result = [0] * (n+1)
    result[0] = 1
    for i in range(1,n+1):
        result[i] = result[i-1] * i % mod
    return result

def nCr(n,r):
    return fact[n] * pow(fact[n-r],mod-2,mod) * pow(fact[r],mod-2,mod) % mod

fact = make_factorial_table(2*N)


for i in range(1,D_max+1):
    if C[i-1] == 1:
        ans *= C[i]
    else:
        ans *= nCr(C[i-1]-1+C[i],C[i-1]-1) % mod
    if ans == 0:
        break
print(ans)
from collections import Counter

N = int(input())
D = list(map(int,input().split()))
C = Counter(D)
mod = 998244353
ans = 1
D_max = max(D)

if D[0] != 0 or C[0] != 1:
    print(0)
    exit()


for i in D[1:]:
    ans *= C[i-1]
    ans %= mod
print(ans)