{"problem":{"name":"Pass to Next","description":{"content":"$N$ people called Person $1, 2, \\ldots, N$ are standing in a circle. For each $1 \\leq i \\leq N-1$, Person $i$'s neighbor to the right is Person $i+1$, and Person $N$'s neighbor to the right is Person ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc124_e"},"statements":[{"statement_type":"Markdown","content":"$N$ people called Person $1, 2, \\ldots, N$ are standing in a circle.\nFor each $1 \\leq i \\leq N-1$, Person $i$'s neighbor to the right is Person $i+1$, and Person $N$'s neighbor to the right is Person $1$.\nPerson $i$ initially has $a_i$ balls.\nThey will do the following procedure just once.\n\n*   Each person chooses some (possibly zero) of the balls they have.\n*   Then, each person **simultaneously** hands the chosen balls to the neighbor to the right.\n*   Now, make a sequence of length $N$, where the $i$\\-th term is the number of balls Person $i$ has at the moment.\n\nLet $S$ be the set of all sequences that can result from the procedure. For example, when $a=(1,1,1)$, we have $S= {(0,1,2),(0,2,1),(1,0,2),(1,1,1),(1,2,0),(2,0,1),(2,1,0) }$.\nCompute $\\sum_{x \\in S} \\prod_{i=1}^{N} x_i$, modulo $998244353$.\n\n## Constraints\n\n*   All values in input are integers.\n*   $3 \\leq N \\leq 10^5$\n*   $0 \\leq a_i \\leq 10^9$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$a_{1}$ $a_{2}$ $\\cdots$ $a_{N}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc124_e","tags":[],"sample_group":[["3\n1 1 1","1\n\n*   We have $S= {(0,1,2),(0,2,1),(1,0,2),(1,1,1),(1,2,0),(2,0,1),(2,1,0) }$.\n*   $\\sum_{x \\in S} \\prod_{i=1}^{N} x_i$ is $1$."],["3\n2 1 1","6"],["20\n5644 493 8410 8455 7843 9140 3812 2801 3725 6361 2307 1522 1177 844 654 6489 3875 3920 7832 5768","864609205\n\n*   Be sure to compute it modulo $998244353$."]],"created_at":"2026-03-03 11:01:14"}}