#include <bits/stdc++.h>
using namespace std;
int n, h;
int a[2005];
int f[2005][2005];
int main() {
  scanf("%d %d", &n, &h);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  f[1][0] = (a[1] == h || a[1] + 1 == h);
  f[1][1] = (a[1] + 1 == h);
  for (int i = 2; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (a[i] + j == h) {
        f[i][j] = (f[i - 1][j - 1] + f[i - 1][j]) % 1000000007;
      }
      if (a[i] + j + 1 == h) {
        f[i][j] =
            (f[i][j] + (long long)(j + 1) * f[i - 1][j + 1] % 1000000007) %
            1000000007;
        f[i][j] = (f[i][j] + (long long)(j + 1) * f[i - 1][j] % 1000000007) %
                  1000000007;
      }
    }
  }
  cout << f[n][0];
}
