Task
After spending a fortnight in Anarchy Acres you have come upon the problem of John's Porks.
Farmer John's farm has been in anarchy ever since he bought his naughty pigs. To bring back order, he has decided to turn exactly of them into officer pigs and hopes they will keep the rest in line. But not every choice of officers will lead to order on the farm.
We know the following:
- the pigs are all arranged in a line in a fixed order
- = the quantity of oats that pig number gets fed in a day
- in order to have a chance at order, the first and last pig must be turned into officers
- having order on the farm means all pigs are well-behaved
We also know that pigs are simple minded creatures, so they only notice the closest officer to their left and the closest to their right. And since pigs are so simple we can predict their behavior based on the following rules:
- an officer pig will always be well-behaved
- if a naughty pig gets strictly less oats than each of the two officers it sees, he will call this a systemic injustice and start a rebellion (will not be well-behaved)
- if a naughty pig gets strictly more oats than each of the two officers it sees, he will feel that he is above the law and start comitting crimes (will not be well-behaved)
- otherwise the naughty pig will be well-behaved
Help John by finding out how many ways of choosing officers will lead to order on his farm.
Two ways of choosing officers are considered different if there exists a pig chosen as officer in one but not in the other.
Input data
The first line of the input contains two positive integers (), representing the total number of pigs, and () representing the number of officer pigs.
The second line of the input contains integers , , , ..., ()
Output data
Let be the number of arrays , , , ..., such that:
- =
- =
- , for all () and ()
Print the value of modulo .
Example 1
stdin
10 7
3 15 3 19 3 3 8 20 7 2
stdout
6
Explanation
There are ways to choose officers:
- ;
- ;
- ;
- ;
- ;
- .
Example 2
stdin
14 8
14 7 13 13 11 12 2 10 11 9 4 7 3 11
stdout
8
Explanation
There are ways to choose officers:
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- .
Example 3
stdin
15 8
5 19 8 7 7 19 19 15 10 11 9 10 9 10 2
stdout
66