#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
const int mod = 1e9 + 7;
int n, h;
long long ans = 1, cnt;
int A[maxn], B[maxn];
int main() {
  scanf("%d%d", &n, &h);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]), A[i] = h - A[i];
  for (int i = 1; i <= n + 1; i++) B[i] = A[i] - A[i - 1];
  for (int i = 1; i <= n + 1; i++) {
    if (B[i] == 1) {
      cnt++;
    } else if (B[i] == 0) {
      ans *= (cnt + 1);
    } else if (B[i] == -1) {
      ans *= cnt;
      cnt--;
    } else {
      ans = 0;
      break;
    }
    ans %= mod;
  }
  printf("%lld\n", ans);
  return 0;
}
