#include <bits/stdc++.h>
using namespace std;
int n, h;
array<int, 2020> a;
const int mod = 1e9 + 7;
int dp[2020][2020];
int go(int id, int open) {
  if (id == n + 1) return 1;
  int &e = dp[id][open];
  if (e == -1) {
    e = 0;
    if (a[id] < a[id - 1]) {
      e = ((1LL * open) * go(id + 1, open - 1)) % mod;
    } else if (a[id] > a[id - 1]) {
      e = go(id + 1, open + 1);
    } else {
      e = ((1LL * (open + 1)) * go(id + 1, open)) % mod;
    }
  }
  return e;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, -1, sizeof(dp));
  cin >> n >> h;
  bool no = 0;
  int prev = 0;
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    k = h - k;
    if (k < 0)
      no = 1;
    else if (k > prev + 1 || k < prev - 1)
      no = 1;
    else if (i == n && k > 1)
      no = 1;
    a[i] = k;
    prev = a[i];
  }
  if (no) {
    cout << 0 << '\n';
    return 0;
  }
  cout << go(1, 0) << '\n';
  return 0;
}
