#include <bits/stdc++.h>
using namespace std;
long long total;
long long arr[2010];
long long dp[2010][2010];
long long K;
long long calc(long long pos, long long open) {
  if (pos == total + 1) {
    if (!open) return 1;
    return 0;
  }
  if (dp[pos][open] != -1) return dp[pos][open];
  long long ans = 0;
  if (arr[pos] + open == K - 1) {
    ans += calc(pos + 1, open + 1);
    ans %= 1000000007;
    ans += calc(pos + 1, open);
    ans %= 1000000007;
    ans += (calc(pos + 1, open) * open) % 1000000007;
  } else if (arr[pos] + open == K) {
    ans += (calc(pos + 1, open - 1) * open) % 1000000007;
    ans %= 1000000007;
    ans += calc(pos + 1, open);
  }
  return dp[pos][open] = ans % 1000000007;
}
int main() {
  scanf("%lld %lld", &total, &K);
  for (long long i = 1; i <= total; i++) {
    scanf("%lld", &arr[i]);
  }
  memset(dp, -1, sizeof dp);
  printf("%lld\n", calc(1, 0));
}
