#include <bits/stdc++.h>
const long long int mo = 1e9 + 7;
const long long int INF = 1e9;
const long double pi = acos(-1);
const int mxn = 2e3 + 50;
const int cons = 1;
using namespace std;
int n, h;
int arr[mxn];
int dp[mxn][mxn];
long long int rec(int ind, int lcount) {
  if (dp[ind][lcount] != -1) {
    return dp[ind][lcount];
  }
  if (ind == n + 1) {
    if (lcount == 0) {
      return dp[ind][lcount] = 1;
    } else {
      return dp[ind][lcount] = 0;
    }
  }
  long long int temp = arr[ind] + lcount;
  if (temp > h || temp < h - 1) {
    return dp[ind][lcount] = 0;
  }
  if (temp == h) {
    return dp[ind][lcount] =
               (lcount * rec(ind + 1, lcount - 1) + rec(ind + 1, lcount)) % mo;
  }
  if (temp == h - 1) {
    return dp[ind][lcount] = (rec(ind + 1, lcount + 1) +
                              (lcount + 1) * rec(ind + 1, lcount)) %
                             mo;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i;
  memset(dp, -1, sizeof(dp));
  cin >> n >> h;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  cout << rec(1, 0) << "\n";
  return 0;
}
