AtCoder Regular Contest 106
F
Figures
AtCoder
⌀ 2755
原题
← E→
翻译中…

Problem Statement

翻译中…

Takahashi is about to assemble a character figure, consisting of $N$ parts called Part $1$, Part $2$, ..., Part $N$ and $N-1$ connecting components. Parts are distinguishable, but connecting components are not.

翻译中…

Part $i$ has $d_i$ holes, called Hole $1$, Hole $2$, ..., Hole $d_i$, into which a connecting component can be inserted. These holes in the parts are distinguishable. Each connecting component will be inserted into two holes in different parts, connecting these two parts. It is impossible to insert multiple connecting components into a hole.

翻译中…

The character figure is said to be complete when it has the following properties:

翻译中…
  • All of the $N-1$ components are used to connect parts.
  • Consider a graph with $N$ vertices corresponding to the parts and $N-1$ undirected edges corresponding to the pairs of vertices connected by a connecting component. Then, this graph is connected.
翻译中…

Two ways A and B to make the figure complete are considered the same when the following is satisfied: for every pair of holes, A uses a connecting component to connect these holes if and only if B uses one to connect them.

翻译中…

Find the number of ways to make the figure complete. Since the answer can be enormous, find the count modulo $998244353$.

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $2 \leq N \leq 2 \times 10^5$
  • $1 \leq d_i < 998244353$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
d_1 d_2 \cdots d_N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3
1 1 3
Output #1
6
One way to make the figure complete is to connect Hole $1$ in Part $1$ and Hole $3$ in Part $3$ and then connect Hole $1$ in Part $2$ and Hole $1$ in Part $3$.
Input #2
3
1 1 1
Output #2
0
Input #3
6
7 3 5 10 6 4
Output #3
389183858
Input #4
9
425656 453453 4320 1231 9582 54336 31435436 14342 423543
Output #4
667877982
题目信息
题号
arc106_f
时间限制
2 s
内存限制
1024 MB

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