#include <bits/stdc++.h>
using namespace std;
long long dp[2000][2001];
int n, h;
int a[2000];
long long mod = 1000 * 1000 * 1000 + 7;
long long solve(int pt, int open) {
  if (pt == n) {
    return open == 0;
  }
  if (dp[pt][open] != -1) return dp[pt][open];
  if (a[pt] + open == h) {
    long long ans = solve(pt + 1, open);
    if (open != 0) {
      ans = (ans + open * solve(pt + 1, open - 1)) % mod;
    }
    return dp[pt][open] = ans;
  } else if (a[pt] + open == h - 1) {
    long long ans = 0;
    ans = solve(pt + 1, open + 1);
    ans = (ans + (open + 1) * solve(pt + 1, open)) % mod;
    return dp[pt][open] = ans;
  } else {
    return dp[pt][open] = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> h;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < 2000; i++) {
    for (int j = 0; j <= 2000; j++) {
      dp[i][j] = -1;
    }
  }
  cout << solve(0, 0);
  return 0;
}
