#include <bits/stdc++.h>
using namespace std;
int n, h;
int a[2005], dp[2005][2005], b[2005];
void upd(int &x, int y) {
  x += y;
  if (x >= 1000000007) x -= 1000000007;
}
int main() {
  int i, j;
  long long ans = 1;
  cin >> n >> h;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]), b[i] = a[i];
    if (a[i] > h) ans = 0;
  }
  n++;
  b[0] = h;
  a[0] = a[n] = h;
  for (i = n; i; i--) {
    a[i] = a[i] - a[i - 1];
    if (a[i] < -1 || a[i] > 1) ans = 0;
  }
  if (ans == 0) {
    printf("0\n");
    return 0;
  }
  dp[0][0] = 1;
  for (i = 1; i <= n; i++)
    for (j = 0; j <= n; j++)
      if (dp[i - 1][j] > 0 && j + b[i - 1] == h) {
        if (a[i] == 1 && j)
          upd(dp[i][j - 1], (long long)j * dp[i - 1][j] % 1000000007);
        else if (a[i] == 0) {
          upd(dp[i][j], (long long)(j + 1) * dp[i - 1][j] % 1000000007);
        } else
          upd(dp[i][j + 1], dp[i - 1][j]);
      }
  cout << dp[n][0] << endl;
  return 0;
}
