#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
const long long oo = (long long)1e9;
const double eps = 1e-9;
const long long mod = 1000000007;
int n, h;
int a[3000];
long long memo[3000][3000];
long long solve(int idx, int add) {
  if (idx == n) {
    if (add == 0) return 1;
    return 0;
  }
  if (memo[idx][add] != -1) return memo[idx][add];
  long long res = 0;
  if (a[idx] + add == h) {
    res += solve(idx + 1, add) % mod;
    res %= mod;
  }
  if (a[idx] + add + 1 == h) {
    res += solve(idx + 1, add + 1) % mod;
    res %= mod;
  }
  if (a[idx] + add == h && add > 0) {
    res += (solve(idx + 1, add - 1) * (add)) % mod;
    res %= mod;
  }
  if (a[idx] + add + 1 == h) {
    res += (solve(idx + 1, add) * (add + 1)) % mod;
    res %= mod;
  }
  return memo[idx][add] = res % mod;
}
int main() {
  memset(memo, -1, sizeof(memo));
  cin >> n >> h;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > h) {
      cout << "0" << endl;
      return 0;
    }
  }
  cout << solve(0, 0) << endl;
  return 0;
}
