#include <bits/stdc++.h>
using namespace std;
const int INF = 303303;
const int Max = 101101;
int n, S, L;
int a[Max];
int lg[Max];
struct sparse {
  int g, h;
};
sparse s[22][Max];
void build_table() {
  for (int i = 1; i <= n; i++) {
    s[0][i].g = a[i];
    s[0][i].h = a[i];
  }
  for (int i = 1; i <= lg[n]; i++) {
    for (int j = 1; j <= n - (1 << i) + 1; j++) {
      s[i][j] = s[i - 1][j];
      int G = s[i - 1][j + (1 << (i - 1))].g;
      int H = s[i - 1][j + (1 << (i - 1))].h;
      if (G < s[i][j].g) s[i][j].g = G;
      if (H > s[i][j].h) s[i][j].h = H;
    }
  }
  return;
}
int get_table(int L, int R) {
  int len = R - L + 1;
  int G1 = s[lg[len]][L].g;
  int H1 = s[lg[len]][L].h;
  int G2 = s[lg[len]][R - (1 << lg[len]) + 1].g;
  int H2 = s[lg[len]][R - (1 << lg[len]) + 1].h;
  int G, H;
  if (G1 <= G2)
    G = G1;
  else
    G = G2;
  if (H1 >= H2)
    H = H1;
  else
    H = H2;
  int result = H - G;
  return result;
}
int tree[Max * 11];
int get(int v, int L, int R, int pos) {
  if (L == R) return tree[v];
  if (pos <= (L + R) / 2)
    return get(2 * v + 1, L, (L + R) / 2, pos);
  else
    return get(2 * v + 2, (L + R) / 2 + 1, R, pos);
}
int get_min(int v, int L, int R, int l, int r) {
  if (l > R || L > r) return INF;
  if (l <= L && R <= r) return tree[v];
  int M1 = get_min(2 * v + 1, L, (L + R) / 2, l, r);
  int M2 = get_min(2 * v + 2, (L + R) / 2 + 1, R, l, r);
  if (M1 <= M2)
    return M1;
  else
    return M2;
}
void push(int v, int L, int R, int pos, int num) {
  if (L == R) {
    tree[v] = num;
    return;
  }
  if (pos <= (L + R) / 2)
    push(2 * v + 1, L, (L + R) / 2, pos, num);
  else
    push(2 * v + 2, (L + R) / 2 + 1, R, pos, num);
  tree[v] = tree[2 * v + 1];
  if (tree[2 * v + 2] < tree[v]) tree[v] = tree[2 * v + 2];
  return;
}
int main() {
  cin >> n >> S >> L;
  for (int i = 1; i <= n; i++) cin >> a[i];
  lg[1] = 0;
  int t = 1;
  for (int i = 2; i <= n; i++) {
    lg[i] = lg[i - 1];
    if (t * 2 == i) {
      t *= 2;
      lg[i]++;
    }
  }
  build_table();
  for (int i = 0; i < Max * 11; i++) tree[i] = INF;
  for (int i = L; i <= n; i++) {
    int raz = get_table(i - L + 1, i);
    if (raz <= S) {
      int LL = 1;
      int RR = i - L + 1;
      int start;
      while (true) {
        if (LL == RR) {
          start = LL;
          break;
        }
        int MM = (LL + RR) / 2;
        int raz_new = get_table(MM, i);
        if (raz_new <= S)
          RR = MM;
        else
          LL = MM + 1;
      }
      if (start == 1)
        push(0, 1, n, i, 1);
      else {
        int dp = get_min(0, 1, n, start - 1, i - L);
        if (dp != INF) push(0, 1, n, i, dp + 1);
      }
    }
  }
  int ans = get(0, 1, n, n);
  if (ans == INF)
    cout << "-1" << endl;
  else
    cout << ans << endl;
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.

Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy:

  * Each piece should contain at least l numbers.
  * The difference between the maximal and the minimal number on the piece should be at most s.



Please help Alexandra to find the minimal number of pieces meeting the condition above.

Input

The first line contains three space-separated integers n, s, l (1 ≤ n ≤ 105, 0 ≤ s ≤ 109, 1 ≤ l ≤ 105).

The second line contains n integers ai separated by spaces ( - 109 ≤ ai ≤ 109).

Output

Output the minimal number of strip pieces.

If there are no ways to split the strip, output -1.

Examples

Input

7 2 2
1 3 1 2 4 1 2


Output

3


Input

7 2 2
1 100 1 100 1 100 1


Output

-1

Note

For the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].

For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 303303;
const int Max = 101101;
int n, S, L;
int a[Max];
int lg[Max];
struct sparse {
  int g, h;
};
sparse s[22][Max];
void build_table() {
  for (int i = 1; i <= n; i++) {
    s[0][i].g = a[i];
    s[0][i].h = a[i];
  }
  for (int i = 1; i <= lg[n]; i++) {
    for (int j = 1; j <= n - (1 << i) + 1; j++) {
      s[i][j] = s[i - 1][j];
      int G = s[i - 1][j + (1 << (i - 1))].g;
      int H = s[i - 1][j + (1 << (i - 1))].h;
      if (G < s[i][j].g) s[i][j].g = G;
      if (H > s[i][j].h) s[i][j].h = H;
    }
  }
  return;
}
int get_table(int L, int R) {
  int len = R - L + 1;
  int G1 = s[lg[len]][L].g;
  int H1 = s[lg[len]][L].h;
  int G2 = s[lg[len]][R - (1 << lg[len]) + 1].g;
  int H2 = s[lg[len]][R - (1 << lg[len]) + 1].h;
  int G, H;
  if (G1 <= G2)
    G = G1;
  else
    G = G2;
  if (H1 >= H2)
    H = H1;
  else
    H = H2;
  int result = H - G;
  return result;
}
int tree[Max * 11];
int get(int v, int L, int R, int pos) {
  if (L == R) return tree[v];
  if (pos <= (L + R) / 2)
    return get(2 * v + 1, L, (L + R) / 2, pos);
  else
    return get(2 * v + 2, (L + R) / 2 + 1, R, pos);
}
int get_min(int v, int L, int R, int l, int r) {
  if (l > R || L > r) return INF;
  if (l <= L && R <= r) return tree[v];
  int M1 = get_min(2 * v + 1, L, (L + R) / 2, l, r);
  int M2 = get_min(2 * v + 2, (L + R) / 2 + 1, R, l, r);
  if (M1 <= M2)
    return M1;
  else
    return M2;
}
void push(int v, int L, int R, int pos, int num) {
  if (L == R) {
    tree[v] = num;
    return;
  }
  if (pos <= (L + R) / 2)
    push(2 * v + 1, L, (L + R) / 2, pos, num);
  else
    push(2 * v + 2, (L + R) / 2 + 1, R, pos, num);
  tree[v] = tree[2 * v + 1];
  if (tree[2 * v + 2] < tree[v]) tree[v] = tree[2 * v + 2];
  return;
}
int main() {
  cin >> n >> S >> L;
  for (int i = 1; i <= n; i++) cin >> a[i];
  lg[1] = 0;
  int t = 1;
  for (int i = 2; i <= n; i++) {
    lg[i] = lg[i - 1];
    if (t * 2 == i) {
      t *= 2;
      lg[i]++;
    }
  }
  build_table();
  for (int i = 0; i < Max * 11; i++) tree[i] = INF;
  for (int i = L; i <= n; i++) {
    int raz = get_table(i - L + 1, i);
    if (raz <= S) {
      int LL = 1;
      int RR = i - L + 1;
      int start;
      while (true) {
        if (LL == RR) {
          start = LL;
          break;
        }
        int MM = (LL + RR) / 2;
        int raz_new = get_table(MM, i);
        if (raz_new <= S)
          RR = MM;
        else
          LL = MM + 1;
      }
      if (start == 1)
        push(0, 1, n, i, 1);
      else {
        int dp = get_min(0, 1, n, start - 1, i - L);
        if (dp != INF) push(0, 1, n, i, dp + 1);
      }
    }
  }
  int ans = get(0, 1, n, n);
  if (ans == INF)
    cout << "-1" << endl;
  else
    cout << ans << endl;
  return 0;
}

```