#include <bits/stdc++.h>
using namespace std;
const int N = 2222;
long long int dp[N][N];
int a[N];
int n, h;
const int MOD = 1000000007;
long long int solve(int idx, int op) {
  if (idx == n + 1) {
    return !op;
  }
  long long int &ret = dp[idx][op];
  if (ret > -1) return ret;
  ret = 0;
  if (a[idx] + op == h) {
    ret = (ret + solve(idx + 1, op)) % MOD;
    if (op) {
      ret = (ret + ((solve(idx + 1, op - 1)) * 1LL * op) % MOD) % MOD;
    }
  } else if (a[idx] + op + 1 == h) {
    ret = (ret + solve(idx + 1, op + 1)) % MOD;
    ret = (ret + ((solve(idx + 1, op)) * 1LL * (op + 1)) % MOD) % MOD;
  }
  return ret;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n >> h;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cout << solve(1, 0);
}
