#include <bits/stdc++.h>
using namespace std;
const long long int mx = 2e3 + 1, Mod = 1e9 + 7;
int n, a[mx], dp[mx][mx], h;
int get(int x, int y) {
  if (y < 0) return 0;
  return dp[x][y];
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> h;
  bool bad = 0;
  for (int i = 1; i <= n; i++) cin >> a[i], bad |= a[i] > h;
  if (bad) return cout << "0\n", 0;
  dp[1][0] = a[1] == h || a[1] == h - 1;
  dp[1][1] = a[1] == h - 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      if (a[i] + j == h - 1)
        dp[i][j] = (dp[i - 1][j + 1] + 1LL * (j + 1) * dp[i - 1][j]) % Mod;
      else if (a[i] + j == h)
        dp[i][j] = (dp[i - 1][j] + 1LL * j * get(i - 1, j - 1)) % Mod;
    }
  }
  cout << dp[n][0] << '\n';
  return 0;
}
