#include <bits/stdc++.h>
const long long MOD = 1000000007;
using namespace std;
long long ans[2005][2005];
int main() {
  long long i, j, k;
  long long A[2005], N, H;
  cin >> N >> H;
  for (i = 0; i < N; i++) {
    cin >> A[i];
  }
  if (A[0] == H - 1) {
    ans[0][0] = 1;
    ans[0][1] = 1;
  }
  if (A[0] == H) {
    ans[0][0] = 1;
  }
  for (i = 1; i <= N; i++) {
    for (j = 0; j <= i + 1; j++) {
      if (A[i] + j == H - 1) {
        ans[i][j] += ans[i - 1][j];
        ans[i][j] %= MOD;
        ans[i][j] += (ans[i - 1][j + 1] * (j + 1));
        ans[i][j] %= MOD;
        if (j > 0) {
          ans[i][j] += (ans[i - 1][j] * j);
          ans[i][j] %= MOD;
        }
      } else if (A[i] + j == H) {
        ans[i][j] += ans[i - 1][j];
        ans[i][j] %= MOD;
        if (j > 0) {
          ans[i][j] += ans[i - 1][j - 1];
          ans[i][j] %= MOD;
        }
      }
    }
  }
  ans[i][j] %= MOD;
  cout << ans[N - 1][0] << '\n';
  return 0;
}
