#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
const int mod = 1e9 + 7;
int a[2010], b[2010];
int n, h;
int solve() {
  long long sum = 1, num = 0;
  for (int i = 1; i <= n + 1; i++) {
    int cnt = b[i] - b[i - 1];
    if (cnt < -1 || cnt > 1) return 0;
    if (cnt == 1) num++;
    if (cnt == -1) {
      sum = num * sum % mod;
      num--;
    }
    if (cnt == 0) sum = (num + 1) * sum % mod;
  }
  return sum;
}
int main() {
  cin >> n >> h;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = h - a[i];
  }
  cout << solve() << endl;
}
