#include <bits/stdc++.h>
using namespace std;
int inp[2010];
vector<int> C;
int abs(int x) { return (x < 0) ? -x : x; }
int main() {
  int n, h, i, j;
  scanf("%d%d", &n, &h);
  for (i = 1; i <= n; i++) {
    scanf("%d", inp + i);
  }
  for (i = 1; i <= n; i++) {
    if (inp[i] > h) {
      printf("0");
      return 0;
    }
  }
  for (i = 1; i <= n; i++) {
    inp[i] = h - inp[i];
  }
  if (inp[1] > 1 || inp[n] > 1) {
    printf("0");
    return 0;
  }
  for (i = 1; i <= n; i++) {
    if (abs(inp[i] - inp[i - 1]) > 1) {
      printf("0");
      return 0;
    }
  }
  int v1 = 0;
  long long int res = 1LL;
  inp[0] = 0;
  for (i = 1; i <= n; i++) {
    if (inp[i] - inp[i - 1] == 0) {
      res *= (long long int)(v1 + 1);
      res %= (long long int)1000000007;
    } else if (inp[i] - inp[i - 1] == 1) {
      v1++;
    } else {
      res *= (long long int)(v1);
      res %= (long long int)1000000007;
      v1--;
    }
  }
  printf("%I64d", res);
}
