#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} debug1;
template <typename T1, typename T2>
inline ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
  bool first = true;
  os << "[";
  for (typename vector<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii) {
    if (!first) os << ", ";
    os << *ii;
    first = false;
  }
  return os << "]";
}
const int NN = 112345;
const int inf = NN * 112;
int rmq_min[20][NN], rmq_max[20][NN];
int inp[NN];
void init(int n) {
  for (int i = 0; i < n; ++i) rmq_min[0][i] = rmq_max[0][i] = inp[i];
  for (int h = 1, ss = 1; ss < n; ++h, ss <<= 1) {
    for (int i = 0; i < n; ++i) {
      if (i + ss >= n) continue;
      rmq_min[h][i] = min(rmq_min[h - 1][i], rmq_min[h - 1][i + ss]);
      rmq_max[h][i] = max(rmq_max[h - 1][i], rmq_max[h - 1][i + ss]);
    }
  }
}
int query_max(int x, int y) {
  if (x > y) swap(x, y);
  int h = log2(y - x + 1);
  int d = (1 << h);
  int ans = max(rmq_max[h][x], rmq_max[h][y - d + 1]);
  return ans;
}
int query_min(int x, int y) {
  if (x > y) swap(x, y);
  int h = log2(y - x + 1);
  int d = (1 << h);
  int ans = min(rmq_min[h][x], rmq_min[h][y - d + 1]);
  return ans;
}
int seg[4 * NN];
void pushup(int node) { seg[node] = min(seg[2 * node], seg[2 * node + 1]); }
void build(int node, int st, int en) {
  if (st == en) {
    seg[node] = inf;
    return;
  }
  int mid = (st + en) / 2;
  build(2 * node, st, mid);
  build(2 * node + 1, mid + 1, en);
  pushup(node);
}
void update(int node, int st, int en, int x, int vv) {
  if (st == en) {
    seg[node] = vv;
    return;
  }
  int mid = (st + en) / 2;
  if (mid >= x)
    update(2 * node, st, mid, x, vv);
  else
    update(2 * node + 1, mid + 1, en, x, vv);
  pushup(node);
}
int query(int node, int st, int en, int L, int R) {
  if (st > en or st > R or en < L) return inf;
  if (st >= L and en <= R) return seg[node];
  int mid = (st + en) / 2;
  int ans = inf;
  ans = min(ans, query(2 * node, st, mid, L, R));
  ans = min(ans, query(2 * node + 1, mid + 1, en, L, R));
  return ans;
}
void solve() {
  int n, D, S;
  scanf("%d%d%d", &n, &S, &D);
  for (int i = 0; i < n; ++i) scanf("%d", &inp[i]);
  init(n);
  build(1, 0, n);
  update(1, 0, n, n, 0);
  for (int i = n - 1; i >= 0; --i) {
    if (i + D > n) continue;
    if ((query_max(i, i + D - 1) - query_min(i, i + D - 1)) > S) continue;
    int st = i + D - 1, en = n - 1;
    int ans = i + D - 1;
    while (st <= en) {
      int mid = (st + en) / 2;
      if (query_max(i, mid) - query_min(i, mid) <= S) {
        ans = mid;
        st = mid + 1;
      } else
        en = mid - 1;
    }
    int up = query(1, 0, n, i + D, ans + 1);
    if (up < inf) update(1, 0, n, i, up + 1);
  }
  int ans = query(1, 0, n, 0, 0);
  if (ans >= inf) ans = -1;
  printf("%d\n", ans);
}
int main() {
  solve();
  return 0;
}

### Prompt

Please formulate a CPP solution 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;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} debug1;
template <typename T1, typename T2>
inline ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
  bool first = true;
  os << "[";
  for (typename vector<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii) {
    if (!first) os << ", ";
    os << *ii;
    first = false;
  }
  return os << "]";
}
const int NN = 112345;
const int inf = NN * 112;
int rmq_min[20][NN], rmq_max[20][NN];
int inp[NN];
void init(int n) {
  for (int i = 0; i < n; ++i) rmq_min[0][i] = rmq_max[0][i] = inp[i];
  for (int h = 1, ss = 1; ss < n; ++h, ss <<= 1) {
    for (int i = 0; i < n; ++i) {
      if (i + ss >= n) continue;
      rmq_min[h][i] = min(rmq_min[h - 1][i], rmq_min[h - 1][i + ss]);
      rmq_max[h][i] = max(rmq_max[h - 1][i], rmq_max[h - 1][i + ss]);
    }
  }
}
int query_max(int x, int y) {
  if (x > y) swap(x, y);
  int h = log2(y - x + 1);
  int d = (1 << h);
  int ans = max(rmq_max[h][x], rmq_max[h][y - d + 1]);
  return ans;
}
int query_min(int x, int y) {
  if (x > y) swap(x, y);
  int h = log2(y - x + 1);
  int d = (1 << h);
  int ans = min(rmq_min[h][x], rmq_min[h][y - d + 1]);
  return ans;
}
int seg[4 * NN];
void pushup(int node) { seg[node] = min(seg[2 * node], seg[2 * node + 1]); }
void build(int node, int st, int en) {
  if (st == en) {
    seg[node] = inf;
    return;
  }
  int mid = (st + en) / 2;
  build(2 * node, st, mid);
  build(2 * node + 1, mid + 1, en);
  pushup(node);
}
void update(int node, int st, int en, int x, int vv) {
  if (st == en) {
    seg[node] = vv;
    return;
  }
  int mid = (st + en) / 2;
  if (mid >= x)
    update(2 * node, st, mid, x, vv);
  else
    update(2 * node + 1, mid + 1, en, x, vv);
  pushup(node);
}
int query(int node, int st, int en, int L, int R) {
  if (st > en or st > R or en < L) return inf;
  if (st >= L and en <= R) return seg[node];
  int mid = (st + en) / 2;
  int ans = inf;
  ans = min(ans, query(2 * node, st, mid, L, R));
  ans = min(ans, query(2 * node + 1, mid + 1, en, L, R));
  return ans;
}
void solve() {
  int n, D, S;
  scanf("%d%d%d", &n, &S, &D);
  for (int i = 0; i < n; ++i) scanf("%d", &inp[i]);
  init(n);
  build(1, 0, n);
  update(1, 0, n, n, 0);
  for (int i = n - 1; i >= 0; --i) {
    if (i + D > n) continue;
    if ((query_max(i, i + D - 1) - query_min(i, i + D - 1)) > S) continue;
    int st = i + D - 1, en = n - 1;
    int ans = i + D - 1;
    while (st <= en) {
      int mid = (st + en) / 2;
      if (query_max(i, mid) - query_min(i, mid) <= S) {
        ans = mid;
        st = mid + 1;
      } else
        en = mid - 1;
    }
    int up = query(1, 0, n, i + D, ans + 1);
    if (up < inf) update(1, 0, n, i, up + 1);
  }
  int ans = query(1, 0, n, 0, 0);
  if (ans >= inf) ans = -1;
  printf("%d\n", ans);
}
int main() {
  solve();
  return 0;
}

```