#include <bits/stdc++.h>
using namespace std;
bool check(long long n, long long pos) { return n & (1LL << pos); }
long long Set(long long n, long long pos) { return n = n | (1LL << pos); }
long long arr[2003];
long long dp[2003][2003];
long long n, m;
long long solve(long long pos, long long cover) {
  if (pos > n) {
    if (cover == 0) return 1;
    return 0;
  }
  long long &ret = dp[pos][cover];
  if (ret != -1) return ret;
  ret = 0;
  if (arr[pos] + cover > m) return ret = 0;
  if (arr[pos] + cover + 1 < m) return ret = 0;
  if (arr[pos] + cover < m) ret += solve(pos + 1, cover + 1);
  if (arr[pos] + cover < m && cover) ret += solve(pos + 1, cover) * cover;
  if (arr[pos] + cover < m) ret += solve(pos + 1, cover);
  if (arr[pos] + cover == m && cover) ret += solve(pos + 1, cover - 1) * cover;
  if (arr[pos] + cover == m) ret += solve(pos + 1, cover);
  return ret = ret % 1000000007;
}
int main() {
  long long i, j, k, l, o, r, q;
  long long testcase;
  long long input, flag, tag, ans;
  while (cin >> n >> m) {
    for (i = 1; i <= n; i++) scanf("%lld", &arr[i]);
    memset(dp, -1, sizeof dp);
    ans = solve(1, 0);
    printf("%lld\n", ans);
  }
}
