#include <bits/stdc++.h>
using namespace std;
const int sqr = 500;
const long long P = (1000 * 1000 * 1000) + 7;
const int arrn = 2e5 + 3;
const int arrn2 = 1e3 + 1;
long long padd(long long a, long long b, long long m) { return (a + b) % m; }
long long psub(long long a, long long b, long long m) { return (a - b) % m; }
long long pmul(long long a, long long b, long long m) { return (a * b) % m; }
int in[2002] = {};
long long ans[2002][2002] = {};
void solve() {
  int n, h;
  cin >> n >> h;
  bool ans1 = true;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
    in[i] = h - in[i];
    if (in[i] < 0) ans1 = false;
  }
  if (!ans1)
    cout << 0;
  else {
    if (in[0] == 0) {
      ans[0][0] = 1;
    } else if (in[0] == 1) {
      ans[0][0] = 1;
      ans[0][1] = 1;
    } else {
      cout << 0;
      return;
    }
    for (int i = 1; i < n; i++) {
      ans[i][in[i]] = padd(ans[i][in[i]], ans[i - 1][in[i]], P);
      if (in[i] > 0) {
        ans[i][in[i]] = padd(ans[i][in[i]], ans[i - 1][in[i] - 1], P);
        ans[i][in[i] - 1] =
            padd(ans[i][in[i] - 1], (in[i] * ans[i - 1][in[i]]) % P, P);
        ans[i][in[i] - 1] =
            padd(ans[i][in[i] - 1], (in[i] * ans[i - 1][in[i] - 1]) % P, P);
      }
    }
    cout << ans[n - 1][0];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int T;
  T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
