#ARC106F. [ARC106F] Figures

[ARC106F] Figures

Score : 800800 points

Problem Statement

Takahashi is about to assemble a character figure, consisting of NN parts called Part 11, Part 22, ..., Part NN and N1N-1 connecting components. Parts are distinguishable, but connecting components are not.

Part ii has did_i holes, called Hole 11, Hole 22, ..., Hole did_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 N1N-1 components are used to connect parts.
  • Consider a graph with NN vertices corresponding to the parts and N1N-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 998244353998244353.

Constraints

  • All values in input are integers.
  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 1di<9982443531 \leq d_i < 998244353

Input

Input is given from Standard Input in the following format:

NN

d1d_1 d2d_2 \cdots dNd_N

Output

Print the answer.

3
1 1 3
6

One way to make the figure complete is to connect Hole 11 in Part 11 and Hole 33 in Part 33 and then connect Hole 11 in Part 22 and Hole 11 in Part 33.

3
1 1 1
0
6
7 3 5 10 6 4
389183858
9
425656 453453 4320 1231 9582 54336 31435436 14342 423543
667877982