{"raw_statement":[{"iden":"problem statement","content":"Given is a sequence of $N$ integers $A_1,A_2,\\ldots,A_N$. Print the number, modulo $998244353$, of sequences of $N$ integers $X_1,X_2,\\ldots,X_N$ satisfying all of the following conditions:\n\n*   $1 \\leq X_i \\leq A_i$\n*   $X_i \\neq X_{i+1} (1 \\leq i \\leq N-1)$"},{"iden":"constraints","content":"*   $2 \\leq N \\leq 5 \\times 10^5$\n*   $1 \\leq A_i \\leq 10^9$"},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\ldots$ $A_N$"},{"iden":"sample input 1","content":"3\n2 3 2"},{"iden":"sample output 1","content":"6\n\nThe following six sequences satisfy all of the conditions.\n\n*   $1,2,1$\n*   $1,3,1$\n*   $1,3,2$\n*   $2,1,2$\n*   $2,3,1$\n*   $2,3,2$"},{"iden":"sample input 2","content":"10\n158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202"},{"iden":"sample output 2","content":"524691026"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}