#include <bits/stdc++.h>
using namespace std;
int n, h;
long long dp[2001][2001];
int a[2001];
int main() {
  cin >> n >> h;
  dp[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    for (long long j = 0; j <= n; j++) {
      if (a[i] + j == h) dp[i][j] += dp[i - 1][j];
      if (a[i] + j == h && j) dp[i][j - 1] += dp[i - 1][j] * j;
      if (a[i] + j + 1 == h && j + 1 <= n) dp[i][j + 1] += dp[i - 1][j];
      if (a[i] + j + 1 == h) dp[i][j] += dp[i - 1][j];
      if (a[i] + j + 1 == h && j) dp[i][j] += dp[i - 1][j] * j;
    }
    for (int j = 0; j <= n; j++) {
      dp[i][j] %= 1000000007;
    }
  }
  cout << dp[n][0] << endl;
}
