{"raw_statement":[{"iden":"problem statement","content":"In this problem, a rooted directed tree is a rooted tree where all edges are directed from the root to the leaves.\nYou are given a sequence of non-negative integers $d=(d_1,d_2,\\ldots,d_N)$ with a sum of $N-1$.\nAmong the $N$\\-vertex rooted directed trees with vertex numbered $1$ to $N$ and vertex $1$ as the root, a **good tree** is one that satisfies the following condition:\n\n*   the out-degree of vertex $i\\ (1\\leq i \\leq N)$ is $d_i$.\n\nFurthermore, for a vertex $v$ of a good tree, let $f(v)$ be the minimum vertex number of the vertices (including $v$) in the subtree rooted at vertex $v$, and $v$ is called a **good vertex** if it satisfies $f(v)=v$.\nFind the sum of the numbers of good vertices for all good trees, modulo $998244353$."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 500$\n*   $0 \\leq d_i \\leq N-1$\n*   $d_1 \\geq 1$\n*   $\\sum_{i=1}^N d_i = N-1$\n*   All input values are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$d_1$ $d_2$ $\\ldots$ $d_N$"},{"iden":"sample input 1","content":"4\n2 0 1 0"},{"iden":"sample output 1","content":"7\n\nThere are two good trees, as shown below. The blue vertices are good vertices.\n![image](https://img.atcoder.jp/arc162/D-sample1-zFXKLnmt.png)\nFor these trees, there are $4$ and $3$ good vertices, respectively, so the answer is $7$."},{"iden":"sample input 2","content":"10\n3 1 0 0 2 0 1 2 0 0"},{"iden":"sample output 2","content":"37542"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}