{"raw_statement":[{"iden":"problem statement","content":"There is a rooted tree with $N$ vertices called Vertex $1$, $2$, $\\ldots$, $N$, rooted at Vertex $1$.\nWe performed a depth-first search starting at the root and obtained a preorder traversal of the tree: $P_1, P_2, \\ldots, P_N$.  \nDuring the search, when the current vertex had multiple children, we chose the unvisited vertex with the smallest index.\nWhat is a preorder traversal?\n\nWe start at the root and repeat the following procedure to list the vertices of the tree.*   If the current vertex $u$ is not recorded yet, record it.\n*   Then, if $u$ has an unvisited vertex, go to that vertex.\n*   Otherwise, terminate if $u$ is the root, and go to the parent of $u$ if it is not.\nThe list of vertices in the order they are recorded here is the preorder traversal of the tree.\n\nFind the number of rooted trees consistent with the preorder traversal, modulo $998244353$.  \nTwo rooted trees (with $N$ vertices and rooted at Vertex $1$) are considered different when there is a non-root vertex whose parent is different in the two trees."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 500$\n*   $1 \\leq P_i\\leq N$\n*   $P_1=1$\n*   All $P_i$ are distinct.\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$P_1$ $P_2$ $\\ldots$ $P_N$"},{"iden":"sample input 1","content":"4\n1 2 4 3"},{"iden":"sample output 1","content":"3\n\nThe rooted trees consistent with the preorder traversal are the three shown below, so the answer is $3$.\n![image](https://img.atcoder.jp/abc252/554e2b202029960276be7564aaa0576b.png)\nNote that the tree below does not count. This is because, among the children of Vertex $2$, we visit Vertex $3$ before visiting Vertex $4$, resulting in the preorder traversal $1,2,3,4$.\n![image](https://img.atcoder.jp/abc252/a6f35bb1addccc64564d36b812669d55.png)"},{"iden":"sample input 2","content":"8\n1 2 3 5 6 7 8 4"},{"iden":"sample output 2","content":"202"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}