#include <bits/stdc++.h>
using namespace std;
int n, h;
int arr[3000];
int dp[2003][2003];
int mod = 1000000007;
int main() {
  cin >> n >> h;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= h; j++) {
      dp[i][j] = 0;
      if (arr[i] + j + 1 == h) {
        dp[i][j] += (1ll * (j + 1) * 1ll * dp[i - 1][j + 1]) % mod;
        if (dp[i][j] >= mod) dp[i][j] -= mod;
        dp[i][j] += (1ll * (j + 1) * 1ll * dp[i - 1][j]) % mod;
        if (dp[i][j] >= mod) dp[i][j] -= mod;
      }
      if (arr[i] + j == h) {
        if (j > 0) dp[i][j] += dp[i - 1][j - 1];
        if (dp[i][j] >= mod) dp[i][j] -= mod;
        dp[i][j] += dp[i - 1][j];
        if (dp[i][j] >= mod) dp[i][j] -= mod;
      }
    }
  }
  cout << dp[n][0] << endl;
}
