#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10, mod = 1e9 + 7;
int dp, n, h, a[N];
int main() {
  dp = 1;
  scanf("%d%d", &n, &h);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    a[i] = h - a[i];
  }
  int ok;
  for (int i = 1; i <= n + 1; ++i) {
    ok = a[i] - a[i - 1];
    if (ok > 1 || ok < -1) {
      printf("0");
      return 0;
    }
    if (ok == 0) dp = 1LL * dp * (a[i] + 1) % mod;
    if (ok == -1) dp = 1LL * dp * (a[i - 1]) % mod;
  }
  printf("%d", dp);
  return 0;
}
