QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#7374. Returning from the Wrong Path

統計

There is a chain with $n+1$ vertices, labeled $0, 1, \dots, n$ from one end to the other. Yiai wants to know how many Eulerian circuits starting and ending at $0$ satisfy the condition that the edge $(i-1, i)$ is traversed exactly $2d_i$ times. You only need to output the answer modulo $998244353$.

Input

The first line contains a positive integer $n$.

The next line contains $n$ positive integers, where the $i$-th integer is $d_i$.

Output

Output an integer representing the number of ways modulo $998244353$.

Examples

Input 1

2
2 1

Output 1

2

Note 1

After taking one step, you can choose to continue forward or turn back; subsequently, there is only one unique choice.

Input 2

4
200 30 8 11

Output 2

812059605

Constraints

For $100\%$ of the data, $1 \le n, d_i \le 10^5$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.