#include <bits/stdc++.h>
using namespace std;
const int TT = 1e9 + 7, N = 2005;
inline int mode(int x) { return x > TT ? x - TT : x; }
int n, h, a[N], C[N][N], sum, cnt, cur;
int calc() {
  int nxt = 0, mul = 1;
  for (int j = 0; j <= cnt; j++)
    nxt = mode(nxt + 1ll * C[cnt][j] * mul % TT), mul = 1ll * mul * sum % TT;
  return nxt;
}
int main() {
  register int i, j;
  for (scanf("%d%d", &n, &h), i = 1; i <= n; i++)
    scanf("%d", &a[i]), a[i] = h - a[i];
  for (C[0][0] = 1, i = 1; i <= n; i++)
    for (C[i][0] = 1, j = 1; j <= i; j++)
      C[i][j] = mode(C[i - 1][j] + C[i - 1][j - 1]);
  for (cur = 1, sum = cnt = 0, i = n; i >= 0; i--) {
    if (sum < 0 || abs(a[i] - a[i + 1]) > 1 || a[i] < 0) return puts("0"), 0;
    if (!a[i] && !a[i + 1]) continue;
    switch (a[i + 1] - a[i]) {
      case 1:
        cur = 1ll * cur * calc() % TT * sum % TT, sum--, cnt = 0;
        break;
      case -1:
        cur = 1ll * cur * calc() % TT, sum++, cnt = 0;
        break;
      case 0:
        cnt++;
        break;
    }
  }
  return printf("%d\n", sum ? 0 : cur), 0;
}
