#arc155f. [arc155_f]Directable as Desired

[arc155_f]Directable as Desired

Problem Statement

You are given a sequence of NN non-negative integers: D=(D1,D2,dots,DN)D=(D_1, D_2, \\dots, D_N).

Find the number of labeled trees with NN vertices numbered 11 to NN that satisfy the following condition, modulo 998244353998244353.

  • There is a way to direct the N1N-1 edges so that the outdegree of each vertex i(1leqileqN)i\\ (1\\leq i \\leq N) is DiD_i.

Constraints

  • 2leqNleq2times1052 \\leq N \\leq 2 \\times 10^5
  • 0leqDileqN10 \\leq D_i \\leq N-1
  • sumi=1NDi=N1\\sum_{i=1}^{N} D_i = N-1
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN D1D_1 D2D_2 dots\\dots DND_N

Output

Print the answer.


Sample Input 1

4
0 1 0 2

Sample Output 1

5

Below are the five trees that satisfy the condition, directed in a desired way.


Sample Input 2

5
0 1 1 1 1

Sample Output 2

125

Sample Input 3

15
0 0 0 0 0 0 0 1 1 1 1 1 2 3 4

Sample Output 3

63282877