#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1000 + 6;
const long long MOD = 1e9 + 7;
long long dp[N][N];
int a[N];
int main() {
  int n, h;
  cin >> n >> h;
  for (int i = 1; i <= n; i++) cin >> a[i];
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] > h) {
      cout << 0;
      return 0;
    }
    int x = h - a[i];
    dp[i][x] = dp[i - 1][x];
    if (x) dp[i][x] += dp[i - 1][x - 1];
    dp[i][x] += dp[i - 1][x + 1] * (x + 1);
    dp[i][x] += dp[i - 1][x] * x;
    dp[i][x] %= MOD;
  }
  if (0 <= h - a[n] && h - a[n] < 2)
    cout << dp[n][h - a[n]] << endl;
  else
    cout << 0 << endl;
  return 0;
}
