#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e3 + 5;
const int MOD = 1e9 + 7;
long long dp[MAX_N][MAX_N];
int a[MAX_N], n, h;
int main() {
  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 < n; j++) {
      if (dp[i][j] != 0) {
        if (a[i + 1] + j == h) {
          dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
          if (j > 0) dp[i + 1][j - 1] = (dp[i + 1][j - 1] + dp[i][j] * j) % MOD;
        }
        if (a[i + 1] + j + 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] * j) % MOD;
          dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
        }
      }
    }
  }
  printf("%I64d\n", dp[n][0]);
  return 0;
}
