AtCoder Regular Contest 115
翻译中…
Problem Statement
翻译中…
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:
翻译中…
$1 \leq X_i \leq A_i$$X_i \neq X_{i+1} (1 \leq i \leq N-1)$
翻译中…
Constraints
翻译中…
$2 \leq N \leq 5 \times 10^5$$1 \leq A_i \leq 10^9$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
A_1 A_2 \ldots A_N
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
3
2 3 2
Output #1
6
The following six sequences satisfy all of the conditions.
- $1,2,1$
- $1,3,1$
- $1,3,2$
- $2,1,2$
- $2,3,1$
- $2,3,2$
Input #2
10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202
Output #2
524691026
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。