#include <bits/stdc++.h>
using namespace std;
int n, k;
int v[2010];
int dp[2010][2010];
long long int DP(int i, int open) {
  if (open < 0) return 0;
  if (i == n + 1) return dp[i][open] = (open == 0) ? 1 : 0;
  if (dp[i][open] != -1) return dp[i][open];
  long long int sum = 0;
  long long int nada = DP(i + 1, open);
  long long int abre = DP(i + 1, open + 1);
  long long int fecha = DP(i + 1, open - 1) * open;
  long long int abre_e_fecha = DP(i + 1, open);
  long long int fecha_e_abre = DP(i + 1, open) * open;
  if (v[i] + open == k) sum = nada + fecha;
  if (v[i] + open + 1 == k) sum = abre + abre_e_fecha + fecha_e_abre;
  return dp[i][open] = sum % 1000000007;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int g = 1; g <= n; g++) scanf("%d", &v[g]);
  memset(dp, -1, sizeof(dp));
  printf("%lld\n", DP(1, 0));
}
