{"raw_statement":[{"iden":"problem statement","content":"Given is a sequence $A$ of $N$ positive integers and a sequence $B$ of $N-1$ positive integers. You can do the following operation any number of times.\n\n*   Choose integers $i$ and $j$ ($1 \\leq i < j \\leq N$) and decrease each of the following values by $1$: $A_i,A_j,B_i,B_{i+1},\\cdots,B_{j-1}$. Here, there should not be any negative value after this operation.\n\nLet $m$ be the maximum number of operations that can be done. Find the number, modulo $998244353$, of sequences that $A$ can be after $m$ operations."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq A_i \\leq 10^9$\n*   $1 \\leq B_i \\leq 10^9$\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$\n$B_1$ $B_2$ $\\cdots$ $B_{N-1}$"},{"iden":"sample input 1","content":"3\n1 2 2\n1 2"},{"iden":"sample output 1","content":"3\n\nWe have $m=2$. After two operations, $A$ will be one of the following three sequences.\n\n*   $A=(1,0,0)$: we end up with this after operations with $(i,j)=(2,3)$ and $(i,j)=(2,3)$.\n*   $A=(0,1,0)$: we end up with this after operations with $(i,j)=(1,3)$ and $(i,j)=(2,3)$.\n*   $A=(0,0,1)$: we end up with this after operations with $(i,j)=(1,2)$ and $(i,j)=(2,3)$."},{"iden":"sample input 2","content":"4\n1 1 1 1\n2 2 2"},{"iden":"sample output 2","content":"1\n\nNote that we do not distinguish two scenarios with different contents of $B$ if the contents of $A$ are the same."},{"iden":"sample input 3","content":"4\n2 2 3 4\n3 1 4"},{"iden":"sample output 3","content":"3"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}