Task
The Spring Carnival has arrived and tourists have reached to the event. We know that all the tourists must wear a hat which is in one of the colors.
The carnival organizers have given each tourist a hat and asked them to sit in a line to take a group picture. However, the picture was lost, but fortunately an observer recorded for each person how many people in front of them had a hat of the same color as the hat they were wearing.
For example, if the array is [], the second person had one person in front of them with the same hat color, while the fifth person had two people with the same hat color in front of them.
Assuming that the carnival organizers have an unlimited number of hats of each of the colors, find out how many different ways exist which could have been used to assign hats to people such that the array the observer recorded would be the same as the array we would record for that given configuration?
Since the answer can be big, print it modulo .
Input
The input will contain on the first line and (), ().
The next line will contain the array ().
For tests worth points, ().
For tests worth more points, ().
Output
The output will contain a single number, representing the answer modulo .
Example 1
stdin
6 4
0 1 0 1 2 3
stdout
24
Example 2
stdin
4 3
0 1 0 0
stdout
6
Explanation
For the second sample test case, the arrays we can generate are:
, , , , ,