#include <bits/stdc++.h>
using namespace std;
const long long INF = 2000000000LL;
const int MOD = 1000000000 + 7;
const int N = 2005;
int dp[N][N];
int a[N];
int n, h;
inline int fun(int i, int open) {
  if (i == n) return open == 0;
  int &r = dp[i][open];
  if (r != -1) return r;
  long long ret = 0;
  if (a[i] + open == h) {
    if (open > 0) ret = (ret + (long long)open * fun(i + 1, open - 1)) % MOD;
    ret = (ret + fun(i + 1, open)) % MOD;
  } else if (a[i] + open + 1 == h) {
    ret = (ret + fun(i + 1, open + 1)) % MOD;
    ret = (ret + (long long)open * fun(i + 1, open)) % MOD;
    ret = (ret + fun(i + 1, open)) % MOD;
  }
  return r = ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  cin >> n >> h;
  for (int i = 0; i < n; ++i) cin >> a[i];
  memset(dp, -1, sizeof dp);
  int res = fun(0, 0);
  cout << res << "\n";
  return 0;
}
