#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll const N = 2001;
ll const M = 1e9 + 7;
ll a[N];
int main() {
  ios_base ::sync_with_stdio(false);
  ll n, h, tot = 1, rem = 0;
  cin >> n >> h;
  for (ll i = 0; i < n; ++i) cin >> a[i];
  for (ll i = 0; i < n; ++i) {
    ll need = h - a[i];
    if (need < 0) return puts("0"), 0;
    if (rem + 1 != need && rem != need && rem - 1 != need) return puts("0"), 0;
    if (rem + 1 != need) tot = tot * (need + 1) % M;
    rem = need;
  }
  if (rem != 1 && rem != 0) tot = 0;
  cout << tot << endl;
  return 0;
}
