#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2010;
long long a[MAXN], dp[MAXN][2];
int n, h;
long long add(long long x, long long y) { return (x + y) % 1000000007; }
long long mul(long long x, long long y) { return (x * y) % 1000000007; }
int main() {
  scanf("%d%d", &n, &h);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = h - a[i];
  }
  a[0] = 0;
  memset(dp, 0, sizeof dp);
  dp[0][0] = 0;
  dp[0][1] = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == a[i - 1] + 1) {
      dp[i][0] = mul(dp[i - 1][1], a[i]);
      dp[i][1] = dp[i - 1][1];
    } else if (a[i] == a[i - 1]) {
      dp[i][0] = mul(add(dp[i - 1][0], dp[i - 1][1]), a[i]);
      dp[i][1] = add(dp[i - 1][0], dp[i - 1][1]);
    } else if (a[i] == a[i - 1] - 1) {
      dp[i][0] = mul(dp[i - 1][0], a[i]);
      dp[i][1] = dp[i - 1][0];
    } else {
      printf("0\n");
      return 0;
    }
  }
  if (a[n] == 1) {
    printf("%d\n", dp[n][0]);
  } else if (a[n] == 0) {
    printf("%d\n", dp[n][1]);
  } else {
    printf("0\n");
  }
  return 0;
}
