#P3154. Counting Possible Score Tables

    ID: 16411 Type: Default 1000ms 256MiB

Counting Possible Score Tables

Counting Possible Score Tables

There are \(n\) teams competing in a tournament. Each pair of teams plays exactly once. In each match, if the game ends in a draw then both teams receive \(1\) point; otherwise, the winning team receives \(3\) points and the losing team receives \(0\) points.

Given the final scores of all teams, determine the number of possible ways to obtain such a score table.

inputFormat

The first line of input contains a single integer \(n\) \((2 \le n \le 10)\), representing the number of teams.

The second line contains \(n\) space-separated integers, where the \(i\)th integer represents the final score of the \(i\)th team.

outputFormat

Output a single integer denoting the number of possible match outcome configurations that result in the given final scores.

sample

3
3 3 3
2