Teams Creation

Count the ways to partition n students into exactly k unnumbered teams so that any two teams are separated by a threshold on skill level.

Medium7CombinatoricsSortingDynamic programmingMathNo attempts yetTime limit2sMemory limit512 MB

Problem

Dr Emmett Brown changed jobs and now teaches computer science at a high school. His class has nn students, and he wants to run a programming contest for them. The classroom has only kk computers, so the contest has to be a team contest.

Dr Brown believes that a team works well when everyone on it has a similar skill level. He knows the skill level aia_i of every student. He wants to split the class so that for any two teams there is a number xx with the following property. Every student on one of the two teams has skill level at most xx, and every student on the other team has skill level at least xx. There must be exactly kk teams, every team must have at least one student, and there is no upper limit on the size of a team.

Count the ways to form the teams. Teams are not numbered. Two ways are different if some two students are on the same team in one of them and on different teams in the other. Report the count modulo 109+710^9 + 7.

Input

The first line contains two integers nn and kk (1n,k20001 \le n, k \le 2000), the number of students in the class and the number of teams that must be created.

The second line contains nn integers aia_i (1ain1 \le a_i \le n), the skill levels of all students.

Output

Print one integer, the number of ways to create the teams modulo 109+710^9 + 7.