{"raw_statement":[{"iden":"problem statement","content":"You are given a permutation $P=(P_1,P_2,\\cdots,P_N)$ of $(1,2,\\cdots,N)$.\nYou may perform the following operation zero or more times.\n\n*   Choose an integer $i$ ($1 \\leq i \\leq N-1$). Let $v=\\max(P_i,P_{i+1})$ and replace the values of $P_i$ and $P_{i+1}$ with $v$.\n\nHow many sequences are there that $P$ can be after your operations? Find the count modulo $998244353$."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 5000$\n*   $(P_1,P_2,\\cdots,P_N)$ is a permutation of $(1,2,\\cdots,N)$.\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$ $\\cdots$ $P_N$"},{"iden":"sample input 1","content":"3\n1 3 2"},{"iden":"sample output 1","content":"4\n\nThe four sequences that $P$ can become are $(1,3,2)$, $(3,3,2)$, $(1,3,3)$, and $(3,3,3)$."},{"iden":"sample input 2","content":"4\n2 1 3 4"},{"iden":"sample output 2","content":"11"},{"iden":"sample input 3","content":"10\n4 9 6 3 8 10 1 2 7 5"},{"iden":"sample output 3","content":"855"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}