#include <bits/stdc++.h>
using namespace std;
long long dp[2010][2010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tt = 1;
  while (tt--) {
    long long n, h;
    cin >> n >> h;
    long long a[n + 1];
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    dp[1][0] = (a[1] == h || a[1] + 1 == h ? 1 : 0);
    dp[1][1] = (a[1] + 1 == h ? 1 : 0);
    for (long long i = 2; i <= n; i++) {
      for (long long j = max(0ll, h - a[i] - 1); j <= min(h - a[i], i); j++) {
        if (a[i] + j == h) {
          dp[i][j] = (dp[i][j] + dp[i - 1][j]) % 1000000007;
          if (j > 0) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % 1000000007;
        }
        if (a[i] + j + 1 == h) {
          dp[i][j] = (dp[i][j] + (dp[i - 1][j + 1] * (j + 1)) % 1000000007) %
                     1000000007;
          dp[i][j] = (dp[i][j] + dp[i - 1][j]) % 1000000007;
          dp[i][j] = (dp[i][j] + (dp[i - 1][j] * j) % 1000000007) % 1000000007;
        }
      }
    }
    cout << dp[n][0] << '\n';
  }
}
