AtCoder Regular Contest 124
E
Pass to Next
AtCoder
⌀ 3031
原题
← DF →
翻译中…

Problem Statement

翻译中…

$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 $1$.

翻译中…

Person $i$ initially has $a_i$ balls.

翻译中…

They will do the following procedure just once.

翻译中…
  • Each person chooses some (possibly zero) of the balls they have.
  • Then, each person simultaneously hands the chosen balls to the neighbor to the right.
  • Now, make a sequence of length $N$, where the $i$-th term is the number of balls Person $i$ has at the moment.
翻译中…

Let $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) \}$.

翻译中…

Compute $\sum_{x \in S} \prod_{i=1}^{N} x_i$, modulo $998244353$.

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $3 \leq N \leq 10^5$
  • $0 \leq a_i \leq 10^9$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
a_{1} a_{2} \cdots a_{N}

翻译中…

Output

翻译中…

Print $\sum_{x \in S} \prod_{i=1}^{N} x_i$, modulo $998244353$.

翻译中…

样例

Input #1
3
1 1 1
Output #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) \}$. - $\sum_{x \in S} \prod_{i=1}^{N} x_i$ is $1$.
Input #2
3
2 1 1
Output #2
6
Input #3
20
5644 493 8410 8455 7843 9140 3812 2801 3725 6361 2307 1522 1177 844 654 6489 3875 3920 7832 5768
Output #3
864609205
- Be sure to compute it modulo $998244353$.
题目信息
题号
arc124_e
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。