eolymp
bolt
Try our new interface for solving problems
Problems

K-inversions

K-inversions

Consider a permutation a1, a2, ..., an (all ai are different integers in range from 1 to n). Let us call k-inversion a sequence of numbers i1, i2, ..., ik such that

1i1 < i2 < ... < ikn

and

ai1 > ai2 > ... > aik.

Your task is to evaluate the number of different k-inversions in a given permutation.

Input

The first line contains two integers n and k (1n20000, 2k10). The second line is filled with n numbers ai.

Output

Output a single number — the number of k-inversions in a given permutation. The number must be taken modulo 109.

Time limit 1 second
Memory limit 64 MiB
Input example #1
3 2
3 1 2
Output example #1
2
Author Dmitry Gozman
Source Dmitry Gozman Contest 1, Petrozavodsk training camp, January 2007