#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 10, MOD = 1e9 + 7;
int n, h, a[N], dp[N][N];
int sum(int a, int b) {
  int c = a + b;
  if (c >= MOD) c -= MOD;
  return c;
}
int mul(int a, int b) { return 1LL * a * b % MOD; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> h;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > h) return cout << 0, 0;
    a[i] = h - a[i];
  }
  if (a[0] > 1) return cout << 0, 0;
  if (a[0] == 0)
    dp[0][0] = 1;
  else
    dp[0][0] = dp[0][1] = 1;
  for (int i = 1; i < n; i++) {
    if ((a[i] - 1) > 0) dp[i][a[i] - 1] = mul((a[i] - 1), dp[i - 1][a[i] - 1]);
    if (a[i] > 0) {
      dp[i][a[i] - 1] = sum(dp[i][a[i] - 1], mul(dp[i - 1][a[i]], a[i]));
      dp[i][a[i] - 1] = sum(dp[i - 1][a[i] - 1], dp[i][a[i] - 1]);
      dp[i][a[i]] = dp[i - 1][a[i] - 1];
    }
    dp[i][a[i]] = sum(dp[i][a[i]], dp[i - 1][a[i]]);
  }
  cout << dp[n - 1][0];
}
