#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int a[N], n;
long long dp[N][N];
long long solve(int pos, int cant) {
  if (pos == n) return cant == 0;
  if (dp[pos][cant] != -1) return dp[pos][cant];
  long long ans = 0;
  if (cant == a[pos]) {
    ans += cant * solve(pos + 1, cant - 1);
    ans += solve(pos + 1, cant);
    ans %= 1000000007;
  }
  if (cant + 1 == a[pos]) {
    ans += (cant + 1) * solve(pos + 1, cant);
    ans += solve(pos + 1, cant + 1);
    ans %= 1000000007;
  }
  return dp[pos][cant] = ans;
}
int main() {
  int altura;
  scanf("%d %d", &n, &altura);
  bool valid = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] > altura) valid = 0;
  }
  if (!valid)
    puts("0");
  else {
    for (int i = 0; i < n; ++i) a[i] = altura - a[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0) << endl;
  }
  return 0;
}
