#asaporo2f. [asaporo2_f]Unicyclic Graph Counting

[asaporo2_f]Unicyclic Graph Counting

Problem Statement

Snuke has come up with the following problem.

You are given a sequence dd of length NN. Find the number of the undirected graphs with NN vertices labeled 1,2,...,N1,2,...,N satisfying the following conditions, modulo 109+710^{9} + 7:

  • The graph is simple and connected.
  • The degree of Vertex ii is did_i.

When $2 \\leq N, 1 \\leq d_i \\leq N-1, {\\rm Σ} d_i = 2(N-1)$, it can be proved that the answer to the problem is $\\frac{(N-2)!}{(d_{1} -1)!(d_{2} - 1)! ... (d_{N}-1)!}$.

Snuke is wondering what the answer is when $3 \\leq N, 1 \\leq d_i \\leq N-1, { \\rm Σ} d_i = 2N$. Solve the problem under this condition for him.

Constraints

  • 3leqNleq3003 \\leq N \\leq 300
  • 1leqdileqN11 \\leq d_i \\leq N-1
  • rmΣdi=2N{ \\rm Σ} d_i = 2N

Partial Scores

  • In the test set worth 200200 points, Nleq5N \\leq 5.
  • In the test set worth another 200200 points, Nleq18N \\leq 18.
  • In the test set worth another 300300 points, Nleq50N \\leq 50.

Input

Input is given from Standard Input in the following format:

NN d1d_1 d2d_2 ...... dNd_{N}

Output

Print the answer.


Sample Input 1

5
1 2 2 3 2

Sample Output 1

6
  • There are six graphs as shown below:

51367cdb21c64bfb07113b300921d52c.png


Sample Input 2

16
2 1 3 1 2 1 4 1 1 2 1 1 3 2 4 3

Sample Output 2

555275958
  • Be sure to find the answer modulo 109+710^{9} + 7.