{"problem":{"name":"Sugoroku 3","description":{"content":"There are $N$ squares called Square $1$ though Square $N$. You start on Square $1$. Each of the squares from Square $1$ through Square $N-1$ has a die on it. The die on Square $i$ is labeled with the ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc263_e"},"statements":[{"statement_type":"Markdown","content":"There are $N$ squares called Square $1$ though Square $N$. You start on Square $1$.\nEach of the squares from Square $1$ through Square $N-1$ has a die on it. The die on Square $i$ is labeled with the integers from $0$ through $A_i$, each occurring with equal probability. (Die rolls are independent of each other.)\nUntil you reach Square $N$, you will repeat rolling a die on the square you are on. Here, if the die on Square $x$ rolls the integer $y$, you go to Square $x+y$.\nFind the expected value, modulo $998244353$, of the number of times you roll a die.\n\n## Constraints\n\n*   $2 \\le N \\le 2 \\times 10^5$\n*   $1 \\le A_i \\le N-i(1 \\le i \\le N-1)$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\dots$ $A_{N-1}$\n\n[samples]\n\n## Notes\n\nIt can be proved that the sought expected value is always a rational number. Additionally, if that value is represented $\\frac{P}{Q}$ using two coprime integers $P$ and $Q$, there is a unique integer $R$ such that $R \\times Q \\equiv P\\pmod{998244353}$ and $0 \\leq R \\lt 998244353$. Find this $R$.","is_translate":false,"language":"English"}],"meta":{"iden":"abc263_e","tags":[],"sample_group":[["3\n1 1","4\n\nThe sought expected value is $4$, so $4$ should be printed.\nHere is one possible scenario until reaching Square $N$:\n\n*   Roll $1$ on Square $1$, and go to Square $2$.\n*   Roll $0$ on Square $2$, and stay there.\n*   Roll $1$ on Square $2$, and go to Square $3$.\n\nThis scenario occurs with probability $\\frac{1}{8}$."],["5\n3 1 2 1","332748122"]],"created_at":"2026-03-03 11:01:14"}}