407816: GYM102897 C BBpigeon Counting Trees
Description
You're given a tree with $$$n$$$ nodes, labeled from $$$1$$$ to $$$n$$$, node $$$1$$$ is the root of the given tree.
The depth of $$$i$$$-$$$th$$$ node is the number of nodes in the path between root and the $$$i$$$-$$$th$$$ node including itself.
Given the depth of each node, please calculate the number of different trees meet the description.
Two trees are considered different iff there exist a node $$$x$$$ have different number of sons in these trees.
InputFirst line contains a positive integer $$$n(1\le n \le 10^5)$$$, the number of nodes.
Second line contains $$$n$$$ integers $$$a_i(1 \leq n \leq 10^5)$$$, the $$$i$$$-$$$th$$$ integer is the depth of node $$$i$$$.
OutputPrint the number of different tree staisfing the description above.
Since the answer could be quite large, you should just module the answer with $$$998244353$$$.
ExamplesInput3 1 2 2Output
1Input
4 1 2 2 3Output
2Note
tree(1) and tree(2) are considered different since $$$3$$$-$$$th$$$ node have different number of sons in these trees.
tree(1) and tree(3) are the same because all nodes have same number of sons in both trees.