#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 100, MOD = 1e9 + 7;
int dp[N][N], a[N];
int n, h;
int sum(int a, int b) { return (a + b) % MOD; }
template <typename Head, typename... Tail>
int sum(Head H, Tail... T) {
  return sum(H, sum(T...));
}
int mul(int a, int b) { return 1LL * a * b % MOD; }
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> h;
  for (int i = 1; i <= n; i++) cin >> a[i];
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] > h) break;
    int j = h - a[i] - 1;
    if (a[i] < h)
      dp[i][j] = sum(dp[i - 1][j], (j ? mul(dp[i - 1][j], j) : 0),
                     mul(dp[i - 1][j + 1], j + 1));
    j++;
    dp[i][j] = sum((j ? dp[i - 1][j - 1] : 0), dp[i - 1][j]);
  }
  return cout << dp[n][0], 0;
}
