#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long ans, x, y, h;
int main() {
  int n;
  scanf("%d%lld", &n, &h);
  ans = 1, y = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &x);
    x = h - x;
    if ((x < 0) || (abs(x - y) > 1)) {
      printf("%d", 0);
      return 0;
    }
    if (x <= y) ans = ans * (x + 1) % MOD;
    y = x;
  }
  if (x > 1)
    printf("0");
  else
    printf("%lld", ans);
}
