#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int n, s, l;
int num[MAXN];
int maxto[MAXN];
template <class T>
struct Segtree {
  T data[2][MAXN << 2];
  void pushup(int o) {
    data[0][o] = max(data[0][(o << 1)], data[0][(o << 1) | 1]);
    data[1][o] = min(data[1][(o << 1)], data[1][(o << 1) | 1]);
  }
  void build(int o, int l, int r) {
    if (l == r) {
      data[0][o] = num[l];
      data[1][o] = num[l];
      return;
    }
    int mid = (l + r) >> 1;
    build((o << 1), l, mid);
    build((o << 1) | 1, mid + 1, r);
    pushup(o);
  }
  T querymax(int o, int l, int r, int x, int y) {
    if (l >= x && r <= y) {
      return data[0][o];
    }
    int mid = (l + r) >> 1;
    if (y <= mid) return querymax((o << 1), l, mid, x, y);
    if (x > mid) return querymax((o << 1) | 1, mid + 1, r, x, y);
    return max(querymax((o << 1), l, mid, x, y),
               querymax((o << 1) | 1, mid + 1, r, x, y));
  }
  T querymin(int o, int l, int r, int x, int y) {
    if (l >= x && r <= y) {
      return data[1][o];
    }
    int mid = (l + r) >> 1;
    if (y <= mid) return querymin((o << 1), l, mid, x, y);
    if (x > mid) return querymin((o << 1) | 1, mid + 1, r, x, y);
    return min(querymin((o << 1), l, mid, x, y),
               querymin((o << 1) | 1, mid + 1, r, x, y));
  }
  T query(int o, int l, int r, int x, int y) {
    return querymax(o, l, r, x, y) - querymin(o, l, r, x, y);
  }
};
template <class T>
struct Segtree1 {
  T data[MAXN << 2];
  T lazy[MAXN << 2];
  void pushup(int o) { data[o] = min(data[(o << 1)], data[(o << 1) | 1]); }
  void build(int o, int l, int r) {
    if (l == r) {
      data[o] = INT_MAX;
      return;
    }
    int mid = (l + r) >> 1;
    build((o << 1), l, mid);
    build((o << 1) | 1, mid + 1, r);
    pushup(o);
  }
  void updateone(int o, int l, int r, int index, T v) {
    if (l == r) {
      data[o] = v;
      return;
    }
    int mid = (l + r) >> 1;
    if (index <= mid)
      updateone((o << 1), l, mid, index, v);
    else
      updateone((o << 1) | 1, mid + 1, r, index, v);
    pushup(o);
  }
  T query(int o, int l, int r, int x, int y) {
    if (l >= x && r <= y) {
      return data[o];
    }
    int mid = (l + r) >> 1;
    if (y <= mid) return query((o << 1), l, mid, x, y);
    if (x > mid) return query((o << 1) | 1, mid + 1, r, x, y);
    return min(query((o << 1), l, mid, x, y),
               query((o << 1) | 1, mid + 1, r, x, y));
  }
};
Segtree<int> tree;
Segtree1<int> dptree;
int binsearch(int now) {
  int L = 1, R = now, mid;
  while (R - L > 3) {
    mid = (R + L) / 2;
    if (tree.query(1, 1, n, mid, now) <= s)
      R = mid;
    else
      L = mid;
  }
  for (int i = L; i <= R; i++) {
    if (tree.query(1, 1, n, i, now) <= s) return i;
  }
  return -1;
}
int main() {
  cin >> n >> s >> l;
  for (int i = 1; i <= n; i++) cin >> num[i];
  if (n < l) {
    cout << -1;
    return 0;
  }
  tree.build(1, 1, n);
  dptree.build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    int le = binsearch(i);
    if (~le && i - le + 1 >= l) {
      if (le == 1)
        dptree.updateone(1, 1, n, i, 1);
      else {
        int t1 = dptree.query(1, 1, n, i, i);
        int t2 = 1 + dptree.query(1, 1, n, le - 1, i - l);
        dptree.updateone(1, 1, n, i, min(t1, t2));
      }
    }
  }
  int ans = dptree.query(1, 1, n, n, n);
  if (ans == INT_MAX || ans == -INT_MAX || ans == INT_MIN)
    cout << -1;
  else
    cout << ans;
  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 MAXN = 100010;
int n, s, l;
int num[MAXN];
int maxto[MAXN];
template <class T>
struct Segtree {
  T data[2][MAXN << 2];
  void pushup(int o) {
    data[0][o] = max(data[0][(o << 1)], data[0][(o << 1) | 1]);
    data[1][o] = min(data[1][(o << 1)], data[1][(o << 1) | 1]);
  }
  void build(int o, int l, int r) {
    if (l == r) {
      data[0][o] = num[l];
      data[1][o] = num[l];
      return;
    }
    int mid = (l + r) >> 1;
    build((o << 1), l, mid);
    build((o << 1) | 1, mid + 1, r);
    pushup(o);
  }
  T querymax(int o, int l, int r, int x, int y) {
    if (l >= x && r <= y) {
      return data[0][o];
    }
    int mid = (l + r) >> 1;
    if (y <= mid) return querymax((o << 1), l, mid, x, y);
    if (x > mid) return querymax((o << 1) | 1, mid + 1, r, x, y);
    return max(querymax((o << 1), l, mid, x, y),
               querymax((o << 1) | 1, mid + 1, r, x, y));
  }
  T querymin(int o, int l, int r, int x, int y) {
    if (l >= x && r <= y) {
      return data[1][o];
    }
    int mid = (l + r) >> 1;
    if (y <= mid) return querymin((o << 1), l, mid, x, y);
    if (x > mid) return querymin((o << 1) | 1, mid + 1, r, x, y);
    return min(querymin((o << 1), l, mid, x, y),
               querymin((o << 1) | 1, mid + 1, r, x, y));
  }
  T query(int o, int l, int r, int x, int y) {
    return querymax(o, l, r, x, y) - querymin(o, l, r, x, y);
  }
};
template <class T>
struct Segtree1 {
  T data[MAXN << 2];
  T lazy[MAXN << 2];
  void pushup(int o) { data[o] = min(data[(o << 1)], data[(o << 1) | 1]); }
  void build(int o, int l, int r) {
    if (l == r) {
      data[o] = INT_MAX;
      return;
    }
    int mid = (l + r) >> 1;
    build((o << 1), l, mid);
    build((o << 1) | 1, mid + 1, r);
    pushup(o);
  }
  void updateone(int o, int l, int r, int index, T v) {
    if (l == r) {
      data[o] = v;
      return;
    }
    int mid = (l + r) >> 1;
    if (index <= mid)
      updateone((o << 1), l, mid, index, v);
    else
      updateone((o << 1) | 1, mid + 1, r, index, v);
    pushup(o);
  }
  T query(int o, int l, int r, int x, int y) {
    if (l >= x && r <= y) {
      return data[o];
    }
    int mid = (l + r) >> 1;
    if (y <= mid) return query((o << 1), l, mid, x, y);
    if (x > mid) return query((o << 1) | 1, mid + 1, r, x, y);
    return min(query((o << 1), l, mid, x, y),
               query((o << 1) | 1, mid + 1, r, x, y));
  }
};
Segtree<int> tree;
Segtree1<int> dptree;
int binsearch(int now) {
  int L = 1, R = now, mid;
  while (R - L > 3) {
    mid = (R + L) / 2;
    if (tree.query(1, 1, n, mid, now) <= s)
      R = mid;
    else
      L = mid;
  }
  for (int i = L; i <= R; i++) {
    if (tree.query(1, 1, n, i, now) <= s) return i;
  }
  return -1;
}
int main() {
  cin >> n >> s >> l;
  for (int i = 1; i <= n; i++) cin >> num[i];
  if (n < l) {
    cout << -1;
    return 0;
  }
  tree.build(1, 1, n);
  dptree.build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    int le = binsearch(i);
    if (~le && i - le + 1 >= l) {
      if (le == 1)
        dptree.updateone(1, 1, n, i, 1);
      else {
        int t1 = dptree.query(1, 1, n, i, i);
        int t2 = 1 + dptree.query(1, 1, n, le - 1, i - l);
        dptree.updateone(1, 1, n, i, min(t1, t2));
      }
    }
  }
  int ans = dptree.query(1, 1, n, n, n);
  if (ans == INT_MAX || ans == -INT_MAX || ans == INT_MIN)
    cout << -1;
  else
    cout << ans;
  return 0;
}

```