#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2000 + 1;
const int mod = 1e9 + 7;
void addto(int& a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mul(int a, int b) { return ((long long)a * b) % mod; }
int mpow(int a, int n) {
  int r = 1;
  while (n > 0) {
    if (n & 1) r = mul(r, a);
    a = mul(a, a);
    n >>= 1;
  }
  return r;
}
int A[MAX_N], h, N;
int dp[MAX_N][MAX_N];
int rec(int n, int k) {
  if (k < 0) return 0;
  if (n == N) return k == 0;
  int& ans = dp[n][k];
  if (ans != -1) return ans;
  ans = 0;
  if (A[n] == k) {
    addto(ans, rec(n + 1, k));
    addto(ans, mul(rec(n + 1, k - 1), k));
  }
  if (A[n] == k + 1) {
    addto(ans, rec(n + 1, k + 1));
    addto(ans, mul(rec(n + 1, k), k + 1));
  }
  return ans;
}
int main() {
  while (scanf("%d%d", &N, &h) != EOF) {
    for (int i = 0; i < N; i++) {
      scanf("%d", A + i);
      A[i] = h - A[i];
    }
    memset(dp, -1, sizeof dp);
    printf("%d\n", rec(0, 0));
  }
  return 0;
}
