{"raw_statement":[{"iden":"problem statement","content":"We have $N$ balls arranged in a row, numbered $1$ to $N$ from left to right. Ball $i$ has an integer $A_i$ written on it.\nYou can do the following operation any number of times.\n\n*   Choose three consecutive balls $x, y, z$ $(1 \\leq x < y < z \\leq N$). Here, $A_x \\neq A_y$ and $A_y \\neq A_z$ must hold. Then, eat Ball $y$. After this operation, Balls $x$ and $z$ are considered adjacent.\n\nFind the number of possible sets of balls remaining in the end, modulo $998244353$."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 200000$\n*   $1 \\leq A_i \\leq 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$A_1$ $A_2$ $\\cdots$ $A_N$"},{"iden":"sample input 1","content":"4\n1 2 1 2"},{"iden":"sample output 1","content":"3\n\nThere are three possible sets of balls remaining in the end: ${1,2,3,4},{1,2,4},{1,3,4}$."},{"iden":"sample input 2","content":"5\n5 4 3 2 1"},{"iden":"sample output 2","content":"8\n\nDifferent sequences of operations are not distinguished if they result in the same set of balls."},{"iden":"sample input 3","content":"5\n1 2 3 2 1"},{"iden":"sample output 3","content":"8\n\nDifferent sets of remaining balls are distinguished even if they have the same sequence of integers written on them."},{"iden":"sample input 4","content":"9\n1 4 2 2 9 6 9 6 6"},{"iden":"sample output 4","content":"14"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}