{"raw_statement":[{"iden":"problem statement","content":"There is a permutation $P$ of $(1,2,\\ldots,N)$ and an empty array $A$. Perform the following operation $N-1$ times on $P$:\n\n*   Choose two adjacent elements. Remove the smaller of the chosen elements from $P$ and concatenate the parts before and after the removed element. Append the removed element to the end of $A$.\n\nFind the number, modulo $998244353$, of possible final sequences $A$ of length $N-1$."},{"iden":"constraints","content":"*   $2 \\le N \\le 2\\times 10^5$\n*   $1 \\le P_i \\le N$\n*   $P$ is a permutation of $(1,2,\\ldots,N)$.\n*   All input values are integers."},{"iden":"input","content":"The 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 3 4"},{"iden":"sample output 1","content":"6\n\nAll six permutations of $(1,2,3)$ are possible as the final $A$.\nFor example, $A=(2,1,3)$ can be obtained as follows:\n\n*   Choose $2,3$. Remove $2$, and now $P=(1,3,4), A=(2)$.\n*   Choose $1,3$. Remove $1$, and now $P=(3,4), A=(2,1)$.\n*   Choose $3,4$. Remove $3$, and now $P=(4), A=(2,1,3)$."},{"iden":"sample input 2","content":"3\n3 1 2"},{"iden":"sample output 2","content":"1"},{"iden":"sample input 3","content":"24\n10 24 3 4 8 14 5 2 22 9 21 1 15 6 13 23 18 12 7 17 19 16 20 11"},{"iden":"sample output 3","content":"303178128"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}