#include <bits/stdc++.h>
using namespace std;
long long n, h, a[2005], need[2005];
long long DP[2005][2005];
long long fact[5005];
long long expo(long long times, long long value) {
  if (times == 0) {
    return 1LL;
  } else if (times == 1) {
    return value;
  } else {
    long long ret = expo(times / 2, value);
    ret %= 1000000007;
    ret *= ret;
    ret %= 1000000007;
    if (times & 1) {
      ret *= value;
    }
    ret %= 1000000007;
    return ret;
  }
}
long long modex(long long value) { return expo(1000000007 - 2, value); }
void reset() {
  for (long long(j) = (0); (j) <= (n); (j)++) {
    for (long long(i) = (0); (i) <= (h); (i)++) {
      DP[j][i] = -1;
    }
  }
  fact[0] = 1;
  for (long long(i) = (1); (i) <= (4000); (i)++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= 1000000007;
  }
}
void input() {
  cin >> n >> h;
  for (long long(i) = (1); (i) <= (n); (i)++) {
    cin >> a[i];
    need[i] = h - a[i];
  }
}
long long Compute(long long n, long long r) {
  long long ret = fact[n];
  ret *= modex(fact[n - r]);
  ret %= 1000000007;
  ret *= modex(fact[r]);
  ret %= 1000000007;
  return ret;
}
long long dp(int i, long long bring) {
  if (i == n + 1) {
    return (bring <= 1);
  } else if (DP[i][bring] != -1) {
    return DP[i][bring];
  } else {
    long long total = 0;
    if (need[i] == bring) {
      total += dp(i + 1, bring) * (bring + 1);
    } else if (need[i] - 1 == bring) {
      total += dp(i + 1, bring + 1);
    } else if (need[i] + 1 == bring) {
      total += dp(i + 1, bring - 1) * (bring);
    }
    total %= 1000000007;
    return DP[i][bring] = total;
  }
}
void solve() {
  for (long long(i) = (1); (i) <= (n); (i)++) {
    if (need[i] < 0) {
      cout << 0 << endl;
      return;
    }
  }
  cout << dp(1, 0) << endl;
}
void LetsRock() { solve(); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  input();
  reset();
  LetsRock();
  return 0;
}

### Prompt

In Cpp, your task is to solve the following problem:

Peter has a sequence of integers a1, a2, ..., an. Peter wants all numbers in the sequence to equal h. He can perform the operation of "adding one on the segment [l, r]": add one to all elements of the sequence with indices from l to r (inclusive). At that, Peter never chooses any element as the beginning of the segment twice. Similarly, Peter never chooses any element as the end of the segment twice. In other words, for any two segments [l1, r1] and [l2, r2], where Peter added one, the following inequalities hold: l1 ≠ l2 and r1 ≠ r2.

How many distinct ways are there to make all numbers in the sequence equal h? Print this number of ways modulo 1000000007 (109 + 7). Two ways are considered distinct if one of them has a segment that isn't in the other way.

Input

The first line contains two integers n, h (1 ≤ n, h ≤ 2000). The next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 2000).

Output

Print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

3 2
1 1 1


Output

4


Input

5 1
1 1 1 1 1


Output

1


Input

4 3
3 2 1 1


Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, h, a[2005], need[2005];
long long DP[2005][2005];
long long fact[5005];
long long expo(long long times, long long value) {
  if (times == 0) {
    return 1LL;
  } else if (times == 1) {
    return value;
  } else {
    long long ret = expo(times / 2, value);
    ret %= 1000000007;
    ret *= ret;
    ret %= 1000000007;
    if (times & 1) {
      ret *= value;
    }
    ret %= 1000000007;
    return ret;
  }
}
long long modex(long long value) { return expo(1000000007 - 2, value); }
void reset() {
  for (long long(j) = (0); (j) <= (n); (j)++) {
    for (long long(i) = (0); (i) <= (h); (i)++) {
      DP[j][i] = -1;
    }
  }
  fact[0] = 1;
  for (long long(i) = (1); (i) <= (4000); (i)++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= 1000000007;
  }
}
void input() {
  cin >> n >> h;
  for (long long(i) = (1); (i) <= (n); (i)++) {
    cin >> a[i];
    need[i] = h - a[i];
  }
}
long long Compute(long long n, long long r) {
  long long ret = fact[n];
  ret *= modex(fact[n - r]);
  ret %= 1000000007;
  ret *= modex(fact[r]);
  ret %= 1000000007;
  return ret;
}
long long dp(int i, long long bring) {
  if (i == n + 1) {
    return (bring <= 1);
  } else if (DP[i][bring] != -1) {
    return DP[i][bring];
  } else {
    long long total = 0;
    if (need[i] == bring) {
      total += dp(i + 1, bring) * (bring + 1);
    } else if (need[i] - 1 == bring) {
      total += dp(i + 1, bring + 1);
    } else if (need[i] + 1 == bring) {
      total += dp(i + 1, bring - 1) * (bring);
    }
    total %= 1000000007;
    return DP[i][bring] = total;
  }
}
void solve() {
  for (long long(i) = (1); (i) <= (n); (i)++) {
    if (need[i] < 0) {
      cout << 0 << endl;
      return;
    }
  }
  cout << dp(1, 0) << endl;
}
void LetsRock() { solve(); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  input();
  reset();
  LetsRock();
  return 0;
}

```