#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
const int mod = 1e9 + 7;
int n, h, a[MAXN], b[MAXN];
int main() {
  scanf("%d%d", &n, &h);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  a[++n] = h;
  for (int i = 1; i <= n; i++) b[i] = h - a[i];
  long long res = 1;
  for (int i = 2; i <= n; i++) {
    if (b[i - 1] == b[i] + 1) {
      res *= b[i - 1];
      res %= mod;
    } else if (b[i - 1] == b[i]) {
      res *= (b[i] + 1);
      res %= mod;
    } else if (b[i - 1] == b[i] - 1) {
      res = res;
    } else {
      res = 0;
      break;
    }
  }
  printf("%lld", res);
}
