#include <bits/stdc++.h>
using namespace std;
template <typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  typename vector<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  typename set<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename F, typename S>
ostream &operator<<(ostream &os, const map<F, S> &v) {
  os << "[";
  typename map<F, S>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
const long double PI = acos(-1.0);
const long long int mod = 1000000007;
const long long int inf = (long long int)1e15;
long long int power(long long int a, long long int b, long long int m = mod) {
  if (b == 0) return 1;
  if (b == 1) return (a % m);
  long long int x = power(a, b / 2, m);
  x = (x * x) % m;
  if (b % 2) x = (x * a) % m;
  return x;
}
long long int max(long long int a, long long int b) { return (a > b ? a : b); }
long long int min(long long int a, long long int b) { return (a < b ? a : b); }
const int N = 2010;
const int M = 1e5 + 5;
int n, h;
int a[N];
int dp[N][N];
bool memo[N][N];
int func(int idx, int open) {
  if (open < 0) return 0;
  if (idx == n + 1) return open == 0;
  if (memo[idx][open]) return dp[idx][open];
  memo[idx][open] = true;
  long long int ret = 0;
  if (a[idx] + open == h) {
    if (open > 0)
      ret += (long long int)func(idx + 1, open - 1) * (long long int)open;
    ret += func(idx + 1, open);
  }
  if (a[idx] + open + 1 == h) {
    ret += (long long int)func(idx + 1, open) * (long long int)(open + 1);
    ret += func(idx + 1, open + 1);
  }
  ret %= mod;
  return dp[idx][open] = ret;
}
void solve() {
  cin >> n >> h;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long int ans = func(1, 0);
  ans %= mod;
  cout << ans << "\n";
  ;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1, num = 1;
  while (t--) {
    solve();
  }
  return 0;
}
