{"raw_statement":[{"iden":"problem statement","content":"You are given a sequence of $N$ positive integers: $A=(A_1,A_2,\\dots,A_N)$.\nHow many integer sequences $B$ consisting of integers between $1$ and $N$ (inclusive) satisfy all of the following conditions? Print the count modulo $998244353$.\n\n*   For each integer $i$ such that $1 \\le i \\le N$, there are exactly $A_i$ occurrences of $i$ in $B$.\n*   For each integer $i$ such that $1 \\le i \\le |B|-1$, it holds that $|B_i - B_{i+1}|=1$."},{"iden":"constraints","content":"*   $1 \\le N \\le 2 \\times 10^5$\n*   $1 \\le A_i \\le 2 \\times 10^5$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\dots$ $A_N$"},{"iden":"sample input 1","content":"3\n2 3 1"},{"iden":"sample output 1","content":"6\n\n$B$ can be the following six sequences.\n\n*   $(1,2,1,2,3,2)$\n*   $(1,2,3,2,1,2)$\n*   $(2,1,2,1,2,3)$\n*   $(2,1,2,3,2,1)$\n*   $(2,3,2,1,2,1)$\n*   $(3,2,1,2,1,2)$\n\nThus, the answer is $6$."},{"iden":"sample input 2","content":"1\n200000"},{"iden":"sample output 2","content":"0\n\nThere may be no sequence that satisfies the conditions."},{"iden":"sample input 3","content":"6\n12100 31602 41387 41498 31863 12250"},{"iden":"sample output 3","content":"750337372"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}