#include <bits/stdc++.h>
using namespace std;
inline int sub(int A, int B) {
  return (((A % 1000000007LL) - (B % 1000000007LL) + 1000000007LL) %
          1000000007LL);
}
inline int add(int A, int B) {
  return ((A % 1000000007LL) + (B % 1000000007LL)) % 1000000007LL;
}
inline int mult(int A, int B) {
  return ((A % 1000000007LL) * (B % 1000000007LL)) % 1000000007LL;
}
int n, h, a[2007], dp[2007][2007];
void solveDP() {
  dp[0][0] = 1;
  a[n + 1] = h;
  for (int i = 0; i <= n; ++i) {
    for (int s = 0; s <= i; ++s) {
      if (s == h - a[i + 1] - 1)
        dp[i + 1][s + 1] = add(dp[i + 1][s + 1], dp[i][s]);
      if (s == h - a[i + 1]) dp[i + 1][s] = add(dp[i + 1][s], dp[i][s]);
      if (s == h - a[i + 1])
        dp[i + 1][s] = add(dp[i + 1][s], mult(s, dp[i][s]));
      if (s == h - a[i + 1] + 1 && s > 0)
        dp[i + 1][s - 1] = add(dp[i + 1][s - 1], mult(s, dp[i][s]));
    }
  }
  cout << dp[n + 1][0];
}
void solve() {
  cin >> n >> h;
  for (int i = 1; i <= (n); ++i) cin >> a[i];
  solveDP();
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}
