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.
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    print('Yes')


if __name__ == '__main__':
    main()

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    N = int(input())
    D = list(map(int, input().split()))

    count = [0] * N
    for d in D:
        count[d] += 1
    
    if D[0] != 0 or count[0] >= 2:
        print(0)
        exit()

    ans = 1
    for i in range(N):
        if i > 0:
            ans *= (count[i-1] ** count[i]) % 998244353
            ans %= 998244353

    print(ans)

    

if __name__ == '__main__':
        main()
