#include <bits/stdc++.h>
using namespace std;
const long long N = 2004;
const long long mod = 1e9 + 7;
long long n, h, dp[N][N], a[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> h;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  if (a[1] + 1 == h || a[1] == h) dp[1][0] = 1;
  if (a[1] + 1 == h) dp[1][1] = 1;
  for (long long i = 2; i <= n; i++) {
    for (long long j = 0; j <= h; j++) {
      if (a[i] + j == h) {
        dp[i][j] = dp[i][j] + dp[i - 1][j - 1];
        dp[i][j] %= mod;
        dp[i][j] = dp[i][j] + dp[i - 1][j];
        dp[i][j] %= mod;
      } else if (a[i] + j + 1 == h) {
        dp[i][j] = dp[i][j] + dp[i - 1][j + 1] * (j + 1);
        dp[i][j] %= mod;
        dp[i][j] = dp[i][j] + dp[i - 1][j];
        dp[i][j] %= mod;
        dp[i][j] = dp[i][j] + dp[i - 1][j] * j;
        dp[i][j] %= mod;
      }
    }
  }
  cout << dp[n][0];
}
