#include <bits/stdc++.h>
using namespace std;
const long long N = 2e3 + 10;
const long long Mod = 1e9 + 7;
long long a[N], n, h, dp[N][N];
signed main() {
  scanf("%lld%lld", &n, &h);
  for (long long i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  if (a[1] == h || a[1] == h - 1) dp[1][0] = 1;
  if (a[1] == h - 1) dp[1][1] = 1;
  for (long long i = 2; i <= n; ++i)
    for (long long j = max(0ll, h - a[i] - 1); j <= min(h - a[i], i); ++j) {
      if (a[i] + j == h) {
        dp[i][j] = (dp[i][j] + dp[i - 1][j]) % Mod;
        if (j) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % Mod;
      } else if (a[i] + j + 1 == h) {
        dp[i][j] =
            (dp[i][j] + (j + 1) * (dp[i - 1][j + 1] + dp[i - 1][j]) % Mod);
      }
    }
  printf("%lld\n", dp[n][0]);
  return 0;
}
