#include <bits/stdc++.h>
const int N = 2002;
const long long MOD = 1000000007;
int a[N];
long long dp[N][N];
int main() {
  int n, h;
  scanf("%d %d", &n, &h);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      if (j + a[i + 1] == h) {
        if (j > 0) dp[i + 1][j - 1] = (dp[i + 1][j - 1] + j * dp[i][j]) % MOD;
        dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
      } else if (j + 1 + a[i + 1] == h) {
        dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
        dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
        if (j > 0) dp[i + 1][j] = (dp[i + 1][j] + j * dp[i][j]) % MOD;
      }
    }
  }
  printf("%d\n", (int)dp[n][0]);
  return 0;
}
