#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int tmax = 2005;
int n, h, a[tmax];
long long ans, num;
int main() {
  scanf("%d%d", &n, &h);
  int i;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > h) return puts("0"), 0;
  }
  if (h - a[1] > 1 || h - a[n] > 1) return puts("0"), 0;
  num = h - a[1];
  ans = 1;
  a[++n] = h;
  for (i = 2; i <= n; i++) {
    if (abs(a[i] - a[i - 1]) > 1) return puts("0"), 0;
    if (a[i] - a[i - 1] == 1) {
      ans = (ans * num) % MOD;
      num--;
    } else if (a[i] - a[i - 1] == -1)
      num++;
    else
      ans = (ans * (num + 1)) % MOD;
  }
  printf("%d", ans);
  return 0;
}
