#include <bits/stdc++.h>
using namespace std;
const int N = 1e9 + 7;
int main() {
  int n, m, a = 1, mul = 1, mu = 1;
  cin >> n >> m;
  int arr[n + 1];
  arr[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    if (i > 1)
      if (arr[i] - arr[i - 1] == 1) a = 0;
  }
  for (int i = 1; i <= n; i++) {
    mul = ((mul % N) * (i % N)) % N;
  }
  for (int i = 1; i <= n - m; i++) mu = ((mu % N) * (i % N)) % N;
  if (a == 1)
    cout << (mul / mu) - 2;
  else
    cout << "0";
}
