#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
int reqd;
int dp[2010][2010];
int solve(int idx, int openSegments) {
  if (idx == (int)arr.size())
    return (openSegments == 0);
  else if (dp[idx][openSegments] != -1)
    return dp[idx][openSegments];
  int ret = 0;
  if (arr[idx] + openSegments == reqd) {
    ret = solve(idx + 1, openSegments);
    ret = (ret + 1LL * solve(idx + 1, openSegments - 1) * openSegments) %
          1000000007;
  } else if (arr[idx] + openSegments + 1 == reqd) {
    ret =
        (1LL * solve(idx + 1, openSegments) * (openSegments + 1)) % 1000000007;
    ret = (ret + solve(idx + 1, openSegments + 1)) % 1000000007;
  }
  return (dp[idx][openSegments] = ret);
}
int main() {
  ios_base::sync_with_stdio(false);
  for (int i = (int)(0); i < (int)(2010); i++)
    for (int j = (int)(0); j < (int)(2010); j++) dp[i][j] = -1;
  int n;
  cin >> n >> reqd;
  arr.resize(n);
  for (int i = (int)(0); i < (int)(n); i++) cin >> arr[i];
  cout << solve(0, 0) << endl;
  return 0;
}
