#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int par[1];
int find(int x) { return x == par[x] ? x : par[x] = find(par[x]); }
void join(int x, int y) { par[find(x)] = y; }
long long mod_expo(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long gcd(long long a, long long b, long long& x, long long& y) {
  if (!a) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
long long dp[2005][2005];
int a[2005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  int n, i, j, K;
  cin >> n >> K;
  for (i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (i = 1; i <= n; ++i) {
    if (a[i] > K) {
      cout << "0\n";
      return 0;
    }
  }
  dp[0][0] = 1;
  for (i = 1; i <= n; ++i) {
    j = K - a[i];
    dp[i][j] += dp[i - 1][j];
    dp[i][j] %= MOD;
    if (j >= 1) {
      dp[i][j] += dp[i - 1][j - 1];
      dp[i][j] %= MOD;
    }
    if (j >= 1) {
      dp[i][j - 1] += dp[i - 1][j - 1] * (j - 1);
      dp[i][j - 1] %= MOD;
      dp[i][j - 1] += dp[i - 1][j] * j;
      dp[i][j - 1] %= MOD;
      dp[i][j - 1] += dp[i - 1][j - 1];
      dp[i][j - 1] %= MOD;
    }
  }
  cout << dp[n][0] << "\n";
  return 0;
}
