{"raw_statement":[{"iden":"problem statement","content":"Snuke has come up with the following problem.\n\n> You are given a sequence $d$ of length $N$. Find the number of the undirected graphs with $N$ vertices labeled $1,2,...,N$ satisfying the following conditions, modulo $10^{9} + 7$:\n> \n> *   The graph is simple and connected.\n> *   The degree of Vertex $i$ is $d_i$.\n\n**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)!}$.\nSnuke 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."},{"iden":"constraints","content":"*   $3 \\leq N \\leq 300$\n*   $1 \\leq d_i \\leq N-1$\n*   ${ \\rm Σ} d_i = 2N$"},{"iden":"partial scores","content":"*   In the test set worth $200$ points, $N \\leq 5$.\n*   In the test set worth another $200$ points, $N \\leq 18$.\n*   In the test set worth another $300$ points, $N \\leq 50$."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$d_1$ $d_2$ $...$ $d_{N}$"},{"iden":"sample input 1","content":"5\n1 2 2 3 2"},{"iden":"sample output 1","content":"6\n\n*   There are six graphs as shown below:\n\n![image](https://atcoder.jp/img/asaporo2/51367cdb21c64bfb07113b300921d52c.png)"},{"iden":"sample input 2","content":"16\n2 1 3 1 2 1 4 1 1 2 1 1 3 2 4 3"},{"iden":"sample output 2","content":"555275958\n\n*   Be sure to find the answer modulo $10^{9} + 7$."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}