#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18, MOD = 1e9 + 7;
const int N = 2e3 + 10, N2 = 3e2 + 10, INFI = 1e9 + 10, L = 19;
int n, h, a[N];
long long dp[N][N];
long long add(long long a, long long b) {
  long long sum = a + b;
  if (sum < 0) {
    sum += MOD;
  }
  if (sum >= MOD) {
    sum -= MOD;
  }
  return sum;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n >> h;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > h) {
      cout << "0\n";
      return 0;
    }
  }
  if (a[0] == h - 1) {
    dp[0][1] = dp[0][0] = 1;
  } else if (a[0] == h) {
    dp[0][0] = 1;
  }
  for (int i = 1; i < n; i++) {
    int r = h - a[i];
    if (r) {
      dp[i][r - 1] = add(dp[i][r - 1], dp[i - 1][r] * r % MOD);
      dp[i][r] = add(dp[i][r], dp[i - 1][r - 1]);
      dp[i][r - 1] = add(dp[i][r - 1], dp[i - 1][r - 1] * (r - 1) % MOD);
      dp[i][r - 1] = add(dp[i][r - 1], dp[i - 1][r - 1]);
    }
    dp[i][r] = add(dp[i][r], dp[i - 1][r]);
  }
  cout << dp[n - 1][0] << endl;
  return 0;
}
