#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
const int N = 2003, mod = 1e9 + 7;
int n, H, a[N], dp[N][N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> H;
  for (int i = (1); i <= (n); ++i) {
    cin >> a[i];
    a[i] = H - a[i];
  }
  for (int i = (1); i <= (n); ++i)
    if (a[i] < 0) {
      cout << 0;
      return 0;
    }
  dp[0][0] = 1;
  for (int i = (1); i <= (n); ++i) {
    if (a[i] - 1 >= 0) {
      dp[i][a[i]] = dp[i - 1][a[i] - 1];
      (dp[i][a[i] - 1] += a[i] * 1ll * dp[i - 1][a[i] - 1] % mod) %= mod;
      (dp[i][a[i] - 1] += (a[i] * 1ll * dp[i - 1][a[i]] % mod)) %= mod;
    }
    (dp[i][a[i]] += dp[i - 1][a[i]]) %= mod;
  }
  cout << dp[n][0];
  return 0;
}
