#K46922. Unique Plant Arrangements

    ID: 28084 Type: Default 1000ms 256MiB

Unique Plant Arrangements

Unique Plant Arrangements

You are given n types of plants, where for each type i there are p_i indistinguishable plants. Your task is to compute the total number of unique arrangements of all these plants in a linear garden bed.

The number of unique arrangements is given by the formula: $$ \frac{(\sum_{i=1}^{n} p_i)!}{\prod_{i=1}^{n} p_i!} $$, where \(\sum_{i=1}^{n} p_i\) is the total number of plants, and \(p_i!\) is the factorial of the count of plants of type i.

inputFormat

The input consists of two lines. The first line contains an integer n representing the number of plant types. The second line contains n space-separated integers where the ith integer represents the number of plants of type i.

outputFormat

Output a single integer which is the total number of unique arrangements of the plants.

## sample
3
1 2 1
12

</p>