#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2033;
const int MOD = 1000000007;
long long e[MAXN][MAXN];
int W[MAXN], n, h;
long long dfs(int k, int opened) {
  if (e[k][opened]) return e[k][opened];
  long long &ans = e[k][opened] = 0;
  if (W[k] + opened == h) {
    ans = (ans + dfs(k - 1, opened)) % MOD;
    if (opened > 0) ans = (ans + dfs(k - 1, opened - 1)) % MOD;
  }
  if (W[k] + opened + 1 == h) {
    ans = (ans + dfs(k - 1, opened) * opened) % MOD;
    ans = (ans + dfs(k - 1, opened + 1) * (opened + 1)) % MOD;
    ans = (ans + dfs(k - 1, opened)) % MOD;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &h);
  for (int i = 1; i <= n; ++i) scanf("%d", &W[i]);
  e[1][0] = (W[1] == h || W[1] + 1 == h);
  e[1][1] = (W[1] + 1 == h);
  printf("%I64d", dfs(n, 0));
  return 0;
}
