Train Tracking 2#10340

Train Tracking 2

Every day, an express train passes by the farm. It has carriages, each labeled with a positive integer from to 10^9; different carriages may have the same label.

Usually Bessie watches the train go by and keeps track of the carriage labels. But today it is too foggy, and Bessie cannot see any of the labels! Luckily, she has obtained the sliding window minimums of the sequence of carriage labels from a reliable source in the city. Specifically, she knows a positive integer and n - k + 1 positive integers c_1, c_2, \ldots, c_{n - k + 1}, where c_i is the minimum label among carriages i, i + 1, \ldots, i + k - 1.

Help Bessie find the number of ways to assign a label to each carriage that are consistent with the sliding window minimums. Since this number can be very large, output it modulo 10^9 + 7.

Bessie's information is completely reliable, that is, it is guaranteed that at least one consistent assignment of labels exists.

Input

The first line contains two integers and k~(1 \le k \le n \le 10^5) — the number of carriages and the window size.

Each of the next n - k + 1 lines contains one integer c_i~(1 \le c_i \le 10^9) — the minimum label among carriages i, i + 1, \ldots, i + k - 1.

Output

Print one integer — the number of ways, modulo 10^9 + 7, to assign to each carriage a positive integer not exceeding 10^9 so that for every i~(1 \le i \le n - k + 1) the minimum label among carriages i, i + 1, \ldots, i + k - 1 equals c_i.

Examples

Example 1

Loading
Loading