#Lutece1056. Just a simple problem again

Just a simple problem again

Migrated from Lutece 1056 Just a simple problem again

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Suffix number i of a string SS is the suffix that starts with the character SiS_i. For example, for S=S=abcde suffix 00 is abcde and suffix 33 is de.

The suffix array of a string SS is defined as the permutation of suffix numbers that corresponds to their lexicographic order. For example, suppose that S=S=abca. If we order all suffixes of SS lexicographically, we get the following: a < abca < bca < ca. The corresponding suffix numbers are 33, 00, 11, and 22, in this order. Thus, for this string S the suffix array would be 3,0,1,2{3, 0, 1, 2}. Note that the length of a suffix array is the same as the length of the original string.

Now Alice is given an array AA: the suffix array of an unknown string. She is wondering how many possible strings satisfying this array if the size of charset is mm.

As is known to everyone of you, Bob loves Alice very much. Could you tell Bob the answer to help Bob leave a good impression on Alice.

Input

The first line contains 22 integers nn and mm, indicating the length of the suffix array and the size of charset.

The next line contains nn integers AiA_i, indicating the element in the suffix array.

It is guaranteed that the suffix array is a permutation of [0,n1][0, n - 1], and 1n,m20000001 \leq n, m \leq 2000000

Output

Print the answer module 1000000007 in one line.

Samples

3 2
0 2 1
1

Resources

The 13th UESTC Programming Contest Final