#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void maximize(T &x, U y) {
  if (x < y) x = y;
}
template <class T, class U>
void minimize(T &x, U y) {
  if (x > y) x = y;
}
template <class T>
T Abs(T x) {
  return (x < 0 ? -x : x);
}
template <class T>
T safe_sqrt(T x) {
  return sqrt(max(x, (T)0));
}
template <class T, class U, class V>
T addmod(T x, U k, V MOD) {
  return ((x + k) % MOD + MOD) % MOD;
}
template <class T, class U, class V>
T submod(T x, U k, V MOD) {
  return ((x - k) % MOD + MOD) % MOD;
}
template <class T, class U, class V>
T mul(T x, U y, V MOD) {
  return (long long)x * y % MOD;
}
namespace taskD {
const int N = 2e3 + 3;
const int base = 1e9 + 7;
long long dp[N][N];
int a[N];
int n, h;
void solve() {
  scanf("%d%d", &n, &h);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= n; j++) {
      if (j + a[i] + 1 == h) {
        dp[i][j] = addmod(dp[i][j], dp[i - 1][j], base);
        dp[i][j] = addmod(dp[i][j], mul(dp[i - 1][j], j, base), base);
        dp[i][j] = addmod(dp[i][j], mul(dp[i - 1][j + 1], j + 1, base), base);
      }
      if (j + a[i] == h and j > 0)
        dp[i][j] = addmod(dp[i][j], dp[i - 1][j - 1], base);
      if (j + a[i] == h) dp[i][j] = addmod(dp[i][j], dp[i - 1][j], base);
    }
  printf("%lld", dp[n][0]);
}
}  // namespace taskD
int main(void) { taskD::solve(); }
