QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 80

#16170. Counting Trees

Statistics

There is a tree with $n$ nodes, denoted as $v_1, v_2, \dots, v_n$. Given the degree $d_i$ of each node $v_i$, determine the number of distinct trees that satisfy these conditions.

Given $n$ and $d_1, d_2, \dots, d_n$, write a program to output the number of trees such that the degree of $v_i$ is $d_i$.

Input

The first line of the input file contains a positive integer $n$, representing the number of nodes in the tree. The second line contains $n$ integers, where the $i$-th number represents $d_i$, the degree of the $i$-th node. It is guaranteed that $1 \le n \le 150$ and the number of such trees does not exceed $10^{17}$.

Output

Output the number of trees that satisfy the given conditions.

Examples

Input 1

4
2 1 2 1

Output 1

2

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.