#include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 10;
const int mod = 1e9 + 7;
int n, h, a[N];
int f[N][N];
void add(int &x, int y) {
  if ((x += y) >= mod) x -= mod;
}
int dfs(int pos, int cnt) {
  if (pos == 1) {
    if (cnt == 0) return a[1] == h || a[1] + 1 == h;
    if (cnt == 1) return a[1] + 1 == h;
    return 0;
  }
  if (~f[pos][cnt]) return f[pos][cnt];
  f[pos][cnt] = 0;
  if (cnt == h - a[pos]) {
    if (cnt) add(f[pos][cnt], dfs(pos - 1, cnt - 1));
    add(f[pos][cnt], dfs(pos - 1, cnt));
  } else if (cnt == h - a[pos] - 1) {
    add(f[pos][cnt], 1LL * dfs(pos - 1, cnt + 1) * (cnt + 1) % mod);
    add(f[pos][cnt], 1LL * dfs(pos - 1, cnt) * (cnt + 1) % mod);
  }
  return f[pos][cnt];
}
int main() {
  memset(f, -1, sizeof(f));
  scanf("%d%d", &n, &h);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  printf("%d\n", dfs(n, 0));
  return 0;
}
