#include <bits/stdc++.h>
using namespace std;
const int N = 2005, K = 55, mod = 998244353;
int n, k, b[N], f[2 * K][N], g[2 * K][N], C[N][N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  f[k][0] = 1;
  for (int i = 1; i <= n; i++) {
    memset(g, 0, sizeof(g));
    for (int j = max(0, k - b[i - 1]); j <= 2 * k; j++) {
      int j2 = j + b[i - 1] - b[i] + 1, x = j + b[i - 1] - k;
      if (x < 0 || x > n || j2 > 2 * k) continue;
      for (int d = max(0, -j2); d < i; d++) {
        if (j2 < 0)
          (g[0][d + j2] += f[j][d]) %= mod;
        else
          (g[j2][d] += f[j][d]) %= mod;
      }
    }
    for (int j = 0; j < 2 * k; j++)
      for (int d = 1; d <= i; d++) (g[j + 1][d - 1] += g[j][d]) %= mod;
    for (int j = max(0, k - b[i - 1]); j <= 2 * k; j++) {
      int j2 = j + b[i - 1] - b[i], x = j + b[i - 1] - k;
      if (x < 0 || x > n || j2 < 0 || j2 > 2 * k) continue;
      for (int d = 0; d < i; d++) {
        (g[j2][d] += 1ll * f[j][d] * (d + x) % mod) %= mod;
        (g[j2][d + 1] += 1ll * f[j][d] * (d + 1) % mod) %= mod;
      }
    }
    swap(f, g);
  }
  C[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < n; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  }
  int ans = 0;
  for (int j = 0; j <= 2 * k; j++) {
    int x = b[n] + j - k;
    if (x < 0 || x > n) continue;
    for (int d = 0; d <= n - x; d++)
      (ans += 1ll * f[j][d] * C[n - x][d] % mod) %= mod;
  }
  printf("%d\n", ans);
  return 0;
}

### Prompt

Create a solution in Cpp for the following problem:

For an array c of nonnegative integers, MEX(c) denotes the smallest nonnegative integer that doesn't appear in it. For example, MEX([0, 1, 3]) = 2, MEX([42]) = 0.

You are given integers n, k, and an array [b_1, b_2, …, b_n].

Find the number of arrays [a_1, a_2, …, a_n], for which the following conditions hold:

  * 0 ≤ a_i ≤ n for each i for each i from 1 to n.

  * |MEX([a_1, a_2, …, a_i]) - b_i| ≤ k for each i from 1 to n.




As this number can be very big, output it modulo 998 244 353.

Input

The first line of the input contains two integers n, k (1 ≤ n ≤ 2000, 0 ≤ k ≤ 50).

The second line of the input contains n integers b_1, b_2, …, b_n (-k ≤ b_i ≤ n+k) — elements of the array b.

Output

Output a single integer — the number of arrays which satisfy the conditions from the statement, modulo 998 244 353.

Examples

Input


4 0
0 0 0 0


Output


256


Input


4 1
0 0 0 0


Output


431


Input


4 1
0 0 1 1


Output


509


Input


5 2
0 0 2 2 0


Output


6546


Input


3 2
-2 0 4


Output


11

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2005, K = 55, mod = 998244353;
int n, k, b[N], f[2 * K][N], g[2 * K][N], C[N][N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  f[k][0] = 1;
  for (int i = 1; i <= n; i++) {
    memset(g, 0, sizeof(g));
    for (int j = max(0, k - b[i - 1]); j <= 2 * k; j++) {
      int j2 = j + b[i - 1] - b[i] + 1, x = j + b[i - 1] - k;
      if (x < 0 || x > n || j2 > 2 * k) continue;
      for (int d = max(0, -j2); d < i; d++) {
        if (j2 < 0)
          (g[0][d + j2] += f[j][d]) %= mod;
        else
          (g[j2][d] += f[j][d]) %= mod;
      }
    }
    for (int j = 0; j < 2 * k; j++)
      for (int d = 1; d <= i; d++) (g[j + 1][d - 1] += g[j][d]) %= mod;
    for (int j = max(0, k - b[i - 1]); j <= 2 * k; j++) {
      int j2 = j + b[i - 1] - b[i], x = j + b[i - 1] - k;
      if (x < 0 || x > n || j2 < 0 || j2 > 2 * k) continue;
      for (int d = 0; d < i; d++) {
        (g[j2][d] += 1ll * f[j][d] * (d + x) % mod) %= mod;
        (g[j2][d + 1] += 1ll * f[j][d] * (d + 1) % mod) %= mod;
      }
    }
    swap(f, g);
  }
  C[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < n; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  }
  int ans = 0;
  for (int j = 0; j <= 2 * k; j++) {
    int x = b[n] + j - k;
    if (x < 0 || x > n) continue;
    for (int d = 0; d <= n - x; d++)
      (ans += 1ll * f[j][d] * C[n - x][d] % mod) %= mod;
  }
  printf("%d\n", ans);
  return 0;
}

```