Task
Kida decided to test you knowledge again. You are given a list , of integers. Kida asks you to count the number of interesting subsets that satisfy the following condition: for any two numbers and in the subset, appears in the subset the same number of times as .
Two subsets are considered different if there is at least one value such that is in one subset but not in the other. Note that two different subsets might contain the exactly same numbers.
Since this number can be very large, you need to count it modulo .
Input
The first line contains the only integer (). The second line contains integers ( for each ).
For tests worth points: ;
For tests worth points: ;
For tests worth points: ;
For tests worth points: No additional limitations.
Output
You need to write a single line with an integer: the number of interesting subsets modulo .
stdin
3
1 2 2
stdout
7
stdin
5
1 2 2 1 3
stdout
21
Notes
In the first sample case, the interesting subsets are , , , , , , .
is not interesting since the number appears twice and the number appears only once.