#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
struct tree {
  int l, r;
  int mid() { return (l + r) / 2; }
  int maxx, minn;
} t[maxn * 4], dp[maxn * 4];
int val[maxn];
int n, s, l;
const int maxx = 1e8 + 9;
void build(int l, int r, int id) {
  t[id].l = l;
  t[id].r = r;
  if (l == r) {
    t[id].maxx = t[id].minn = val[l];
    return;
  }
  int mid = t[id].mid();
  build(l, mid, ((id) << 1));
  build(mid + 1, r, ((id) << 1 | 1));
  t[id].maxx = max(t[((id) << 1)].maxx, t[((id) << 1 | 1)].maxx);
  t[id].minn = min(t[((id) << 1)].minn, t[((id) << 1 | 1)].minn);
  return;
}
int query_max(int l, int r, int id) {
  if (l == t[id].l && r == t[id].r) return t[id].maxx;
  int mid = t[id].mid();
  if (r <= mid)
    return query_max(l, r, ((id) << 1));
  else if (mid < l)
    return query_max(l, r, ((id) << 1 | 1));
  else
    return max(query_max(l, mid, ((id) << 1)),
               query_max(mid + 1, r, ((id) << 1 | 1)));
}
int query_min(int l, int r, int id) {
  if (l == t[id].l && r == t[id].r) return t[id].minn;
  int mid = t[id].mid();
  if (r <= mid)
    return query_min(l, r, ((id) << 1));
  else if (mid < l)
    return query_min(l, r, ((id) << 1 | 1));
  else
    return min(query_min(l, mid, ((id) << 1)),
               query_min(mid + 1, r, ((id) << 1 | 1)));
}
void build2(int l, int r, int id) {
  dp[id].l = l;
  dp[id].r = r;
  dp[id].minn = maxx;
  if (l == r) return;
  int mid = dp[id].mid();
  build2(l, mid, ((id) << 1));
  build2(mid + 1, r, ((id) << 1 | 1));
  return;
}
void update(int pos, int v, int id) {
  if (dp[id].l == dp[id].r) {
    dp[id].minn = min(dp[id].minn, v);
    return;
  }
  int m = dp[id].mid();
  if (pos <= m)
    update(pos, v, ((id) << 1));
  else
    update(pos, v, ((id) << 1 | 1));
  dp[id].minn = min(dp[((id) << 1)].minn, dp[((id) << 1 | 1)].minn);
}
int query(int l, int r, int id) {
  if (l > r) return maxx;
  if (l == dp[id].l && r == dp[id].r) return dp[id].minn;
  int m = dp[id].mid();
  if (m >= r)
    return query(l, r, ((id) << 1));
  else if (m < l)
    return query(l, r, ((id) << 1 | 1));
  else
    return min(query(l, m, ((id) << 1)), query(m + 1, r, ((id) << 1 | 1)));
}
int main() {
  scanf("%d %d %d", &n, &s, &l);
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  build(1, n, 1);
  build2(1, n, 1);
  for (int i = l; i <= n; i++) {
    int left = 0, right = i - l;
    int mid;
    while (left < right) {
      mid = (left + right) / 2;
      if (query_max(mid + 1, i, 1) - query_min(mid + 1, i, 1) <= s)
        right = mid;
      else
        left = mid + 1;
    }
    if (query_max(left + 1, i, 1) - query_min(left + 1, i, 1) <= s) {
      if (left == 0)
        update(i, 1, 1);
      else {
        int now = query(left, i - l, 1);
        if (now + 1 <= maxx) update(i, now + 1, 1);
      }
    }
  }
  cout << (query(n, n, 1) == maxx ? -1 : query(n, n, 1)) << endl;
  return 0;
}

### Prompt

Please create a solution in cpp to the following problem:

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 = 1e5 + 7;
struct tree {
  int l, r;
  int mid() { return (l + r) / 2; }
  int maxx, minn;
} t[maxn * 4], dp[maxn * 4];
int val[maxn];
int n, s, l;
const int maxx = 1e8 + 9;
void build(int l, int r, int id) {
  t[id].l = l;
  t[id].r = r;
  if (l == r) {
    t[id].maxx = t[id].minn = val[l];
    return;
  }
  int mid = t[id].mid();
  build(l, mid, ((id) << 1));
  build(mid + 1, r, ((id) << 1 | 1));
  t[id].maxx = max(t[((id) << 1)].maxx, t[((id) << 1 | 1)].maxx);
  t[id].minn = min(t[((id) << 1)].minn, t[((id) << 1 | 1)].minn);
  return;
}
int query_max(int l, int r, int id) {
  if (l == t[id].l && r == t[id].r) return t[id].maxx;
  int mid = t[id].mid();
  if (r <= mid)
    return query_max(l, r, ((id) << 1));
  else if (mid < l)
    return query_max(l, r, ((id) << 1 | 1));
  else
    return max(query_max(l, mid, ((id) << 1)),
               query_max(mid + 1, r, ((id) << 1 | 1)));
}
int query_min(int l, int r, int id) {
  if (l == t[id].l && r == t[id].r) return t[id].minn;
  int mid = t[id].mid();
  if (r <= mid)
    return query_min(l, r, ((id) << 1));
  else if (mid < l)
    return query_min(l, r, ((id) << 1 | 1));
  else
    return min(query_min(l, mid, ((id) << 1)),
               query_min(mid + 1, r, ((id) << 1 | 1)));
}
void build2(int l, int r, int id) {
  dp[id].l = l;
  dp[id].r = r;
  dp[id].minn = maxx;
  if (l == r) return;
  int mid = dp[id].mid();
  build2(l, mid, ((id) << 1));
  build2(mid + 1, r, ((id) << 1 | 1));
  return;
}
void update(int pos, int v, int id) {
  if (dp[id].l == dp[id].r) {
    dp[id].minn = min(dp[id].minn, v);
    return;
  }
  int m = dp[id].mid();
  if (pos <= m)
    update(pos, v, ((id) << 1));
  else
    update(pos, v, ((id) << 1 | 1));
  dp[id].minn = min(dp[((id) << 1)].minn, dp[((id) << 1 | 1)].minn);
}
int query(int l, int r, int id) {
  if (l > r) return maxx;
  if (l == dp[id].l && r == dp[id].r) return dp[id].minn;
  int m = dp[id].mid();
  if (m >= r)
    return query(l, r, ((id) << 1));
  else if (m < l)
    return query(l, r, ((id) << 1 | 1));
  else
    return min(query(l, m, ((id) << 1)), query(m + 1, r, ((id) << 1 | 1)));
}
int main() {
  scanf("%d %d %d", &n, &s, &l);
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  build(1, n, 1);
  build2(1, n, 1);
  for (int i = l; i <= n; i++) {
    int left = 0, right = i - l;
    int mid;
    while (left < right) {
      mid = (left + right) / 2;
      if (query_max(mid + 1, i, 1) - query_min(mid + 1, i, 1) <= s)
        right = mid;
      else
        left = mid + 1;
    }
    if (query_max(left + 1, i, 1) - query_min(left + 1, i, 1) <= s) {
      if (left == 0)
        update(i, 1, 1);
      else {
        int now = query(left, i - l, 1);
        if (now + 1 <= maxx) update(i, now + 1, 1);
      }
    }
  }
  cout << (query(n, n, 1) == maxx ? -1 : query(n, n, 1)) << endl;
  return 0;
}

```