Eating Snacks
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Eating Snacks
Time limit: 1.5 seconds
Memory limit: 512 megabytes
Problem Statement
As a foodie, Diana loves eating snacks. Diana plan to eat packs of snacks on -th day within days, and if she plan to eat snacks on day , she will definitely eat up all the packs of snacks.
But strict team leader Bella will control the number of snacks Diana eats to prevent her from getting fat! Bella will control Diana eat snacks by some rules:
1.She can only eat snacks for days strictly.
2.Within days, the number of snacks eaten each day must be strictly less than the number of snacks eaten the previous day (excluding the first day).
3.Diana can start eating from any day.
But Bella is a good woman, so she relax the limit !
If Diana comply with the second rule on -th day within days, then Bella will allow her not to comply with the second rule on -th day. Surely, Diana will definitely choose to eat snacks on -th day than on -th day.
, on -st day Diana considered to have failed to comply with the second rule.
Now Diana wants to know how many ways to choose days from days to meet the above conditions.
Since the answer may be very large, you only need to print the result modulo .
Input
The first line contains two integers .
The second contains integers, the -th number denoting .
Output
Print a single integer, denoting the answer to the question modulo .
5 5
2 1 3 1 2
1
5 5
1 2 1 3 1
0
5 1
2 1 3 1 2
5
7 3
2 1 3 1 2 3 2
11
Hints
On first sample and second sample has only one subsequence which length equals .
On first sample, Diana can start eating on first day, but the number of snacks eaten on the second day must be less than that on the first day, the number of snacks eaten on the third day must be more than on the second day...
On second sample, Diana start eating on first day, but the number of snacks eaten on the second day more than that on the first day. So the answer equals 0.