#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long dp[2222][2222];
long long arr[2222], n, h;
long long fun(int pos, int cur) {
  if (pos == n) return cur == 0;
  long long& ret = dp[pos][cur];
  if (ret != -1) return ret;
  ret = 0;
  if (arr[pos] == cur) {
    ret = fun(pos + 1, cur);
    ret %= mod;
    if (cur) {
      ret += (fun(pos + 1, cur - 1) * (cur)) % mod;
      ret %= mod;
    }
  } else if (arr[pos] == cur + 1) {
    ret += fun(pos + 1, cur + 1);
    ret %= mod;
    ret += (1LL * fun(pos + 1, cur) * (cur + 1)) % mod;
    ret %= mod;
  }
  ret %= mod;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> h;
  for (int i(0), _n(n); i < _n; ++i) {
    cin >> arr[i];
    arr[i] = h - arr[i];
    if (arr[i] < 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  memset(dp, -1, sizeof(dp));
  cout << fun(0, 0) << endl;
}
