#P1158F. Density of subarrays
Density of subarrays
No submission language available for this problem.
Description
Let be some positive integer. Let's call an array of positive integers -array, if for all condition is satisfied. Let's call -array a subarray of -array , if there exists such set of indices that for all . Let's define density of -array as maximal non-negative integer , such that any -array, that contains numbers is a subarray of .
You are given a number and some -array . For all find the number of sequences of indices for all , such that density of array is equal to . Find these numbers by modulo , because they can be too large.
The first line contains two integers and , separated by spaces (). The second line contains integers , separated by spaces ().
Print numbers . should be equal to the number of sequences of indices for all by modulo , such that the density of array is equal to .
Input
The first line contains two integers and , separated by spaces (). The second line contains integers , separated by spaces ().
Output
Print numbers . should be equal to the number of sequences of indices for all by modulo , such that the density of array is equal to .
Samples
Note
In the first example, it's easy to see that the density of array will always be equal to its length. There exists sequences with one index, with two indices, with three and with four.
In the second example, the only sequence of indices, such that the array will have non-zero density is all indices because in other cases there won't be at least one number from to in the array, so it won't satisfy the condition of density for .