#ablf. [abl_f]Heights and Pairs
[abl_f]Heights and Pairs
Problem Statement
There are people numbered through . The height of Person is .
How many ways are there to make pairs of people such that the following conditions are satisfied? Compute the answer modulo .
- Each person is contained in exactly one pair.
- For each pair, the heights of the two people in the pair are different.
Two ways are considered different if for some and , Person and Person are paired in one way and not in the other.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2
1
1
2
3
Sample Output 1
2
There are two ways:
- Form the pair (Person , Person ) and the pair (Person , Person ).
- Form the pair (Person , Person ) and the pair (Person , Person ).
Sample Input 2
5
30
10
20
40
20
10
10
30
50
60
Sample Output 2
516