#include <bits/stdc++.h>
using namespace std;
void setIO(const string &name = "") {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  if (name.length()) {
    freopen((name + ".in").c_str(), "r", stdin);
    freopen((name + ".out").c_str(), "w", stdout);
  }
}
template <typename T>
void read(vector<T> &a) {
  for (auto &x : a) cin >> x;
}
template <typename T>
void read(vector<T> &a, int n) {
  a.resize(n);
  for (auto &x : a) cin >> x;
}
template <class T, class U>
ostream &operator<<(ostream &out, const pair<T, U> &v) {
  out << "(";
  out << v.first << "," << v.second;
  return out << ")";
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  for (auto(i) = 0; (i) < ((int)(v).size()); (i)++) {
    if (i) out << ", ";
    out << v[i];
  }
  return out << "]";
}
template <typename T>
void print(vector<T> &a) {
  for (const auto &x : a) cout << x << ' ';
  cout << '\n';
}
void MOD(int &x, int m = 1000000007) {
  x %= m;
  if (x < 0) x += m;
}
template <typename T>
void dbg(const char *name, T &&arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename T, typename... U>
void dbg(const char *names, T &&arg1, U &&...args) {
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  dbg(comma + 1, args...);
}
template <class T>
void read(T &x) {
  cin >> x;
}
template <class T, class... U>
void read(T &t, U &...u) {
  read(t);
  read(u...);
}
int gcd(int a, int b) { return !a ? b : gcd(b % a, a); }
struct SegTree {
  int size = 1;
  vector<int> elements, a;
  void init(int n) {
    while (size < n) size *= 2;
    elements.assign(2 * size, int(1e9 + 5));
  }
  void pull(int x) {
    elements[x] = min(elements[2 * x + 1], elements[2 * x + 2]);
  }
  void build(int x, int lx, int rx) {
    if (rx - lx == 1) {
      if (lx < (int)(a).size()) {
        elements[x] = a[lx];
      }
      return;
    }
    int mid = (lx + rx) / 2;
    build(2 * x + 1, lx, mid);
    build(2 * x + 2, mid, rx);
    pull(x);
  }
  void build(const vector<int> &x) {
    a = x;
    build(0, 0, size);
  }
  void set(int i, int v, int x, int lx, int rx) {
    if (rx - lx == 1) {
      elements[x] = v;
      return;
    }
    int mid = (lx + rx) / 2;
    if (i < mid) {
      set(i, v, 2 * x + 1, lx, mid);
    } else {
      set(i, v, 2 * x + 2, mid, rx);
    }
    pull(x);
  }
  void set(int i, int v) { set(i, v, 0, 0, size); }
  int calc(int l, int r, int x, int lx, int rx) {
    if (l >= rx or r <= lx) return int(1e9 + 5);
    if (l <= lx and rx <= r) return elements[x];
    int mid = (lx + rx) / 2;
    int r1 = calc(l, r, 2 * x + 1, lx, mid);
    int r2 = calc(l, r, 2 * x + 2, mid, rx);
    return min(r1, r2);
  }
  int calc(int l, int r) { return calc(l, r, 0, 0, size); }
};
struct SparseTableMIN {
  int size = 1;
  vector<int> v;
  vector<int> log_table;
  void makeLogTable() {
    for (auto(i) = 2; (i) < ((int)(log_table).size()); (i)++) {
      log_table[i] = log_table[i / 2] + 1;
    }
  }
  vector<vector<int> > table;
  void makeTable() {
    table.resize(log_table.back() + 1, vector<int>((int)(v).size()));
    table[0] = v;
    for (auto(row) = 1; (row) < ((int)(table).size()); (row)++) {
      const int pow2_before = 1 << (row - 1);
      const int pow2 = 1 << row;
      for (int i = 0; i + pow2 <= (int)(v).size(); i++) {
        table[row][i] = min(table[row - 1][i], table[row - 1][i + pow2_before]);
      }
    }
  }
  void init(int n, vector<int> &inp) {
    size = n;
    v.resize(n);
    for (auto(i) = 0; (i) < (n); (i)++) v[i] = inp[i];
    log_table.assign(n + 1, 0);
    makeLogTable();
    makeTable();
  }
  int calc(int l, int r) {
    int lg = log_table[r - l];
    int mnm = min(table[lg][l], table[lg][r - (1 << lg)]);
    return mnm;
  }
};
struct SparseTableMAX {
  int size = 1;
  vector<int> v;
  vector<int> log_table;
  void makeLogTable() {
    for (auto(i) = 2; (i) < ((int)(log_table).size()); (i)++) {
      log_table[i] = log_table[i / 2] + 1;
    }
  }
  vector<vector<int> > table;
  void makeTable() {
    table.resize(log_table.back() + 1, vector<int>((int)(v).size()));
    table[0] = v;
    for (auto(row) = 1; (row) < ((int)(table).size()); (row)++) {
      const int pow2_before = 1 << (row - 1);
      const int pow2 = 1 << row;
      for (int i = 0; i + pow2 <= (int)(v).size(); i++) {
        table[row][i] = max(table[row - 1][i], table[row - 1][i + pow2_before]);
      }
    }
  }
  void init(int n, vector<int> &inp) {
    size = n;
    v.resize(n);
    for (auto(i) = 0; (i) < (n); (i)++) v[i] = inp[i];
    log_table.assign(n + 1, 0);
    makeLogTable();
    makeTable();
  }
  int calc(int l, int r) {
    int lg = log_table[r - l];
    int mnm = max(table[lg][l], table[lg][r - (1 << lg)]);
    return mnm;
  }
};
int n, max_diff, min_size;
vector<int> a;
int dp[int(1e5 + 10)];
SegTree st;
SparseTableMIN st_min;
SparseTableMAX st_max;
int32_t main() {
  setIO();
  read(n, max_diff, min_size);
  read(a, n);
  st.init(n);
  st_min.init(n, a);
  st_max.init(n, a);
  auto bin = [&](int idx) {
    int lo = idx, hi = n - 1;
    int res = -1, mid, mx, mn;
    while (lo <= hi) {
      mid = (lo + hi) / 2;
      mx = st_max.calc(idx, mid + 1);
      mn = st_min.calc(idx, mid + 1);
      if (mx - mn <= max_diff) {
        res = mid;
        lo = mid + 1;
      } else {
        hi = mid - 1;
      }
    }
    return res;
  };
  dp[n - 1] = int(1e9 + 5);
  if (min_size == 1) dp[n - 1] = 1;
  st.set(n - 1, 0);
  int idx;
  for (int i = n - 2; i >= 0; i--) {
    idx = bin(i);
    st.set(i, dp[i + 1]);
    if (idx >= i + min_size - 1) {
      dp[i] = st.calc(i + min_size - 1, idx + 1) + 1;
    } else {
      dp[i] = int(1e9 + 5);
    }
  }
  if (dp[0] > n) {
    dp[0] = -1;
  }
  cout << dp[0] << '\n';
  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;
void setIO(const string &name = "") {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  if (name.length()) {
    freopen((name + ".in").c_str(), "r", stdin);
    freopen((name + ".out").c_str(), "w", stdout);
  }
}
template <typename T>
void read(vector<T> &a) {
  for (auto &x : a) cin >> x;
}
template <typename T>
void read(vector<T> &a, int n) {
  a.resize(n);
  for (auto &x : a) cin >> x;
}
template <class T, class U>
ostream &operator<<(ostream &out, const pair<T, U> &v) {
  out << "(";
  out << v.first << "," << v.second;
  return out << ")";
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  for (auto(i) = 0; (i) < ((int)(v).size()); (i)++) {
    if (i) out << ", ";
    out << v[i];
  }
  return out << "]";
}
template <typename T>
void print(vector<T> &a) {
  for (const auto &x : a) cout << x << ' ';
  cout << '\n';
}
void MOD(int &x, int m = 1000000007) {
  x %= m;
  if (x < 0) x += m;
}
template <typename T>
void dbg(const char *name, T &&arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename T, typename... U>
void dbg(const char *names, T &&arg1, U &&...args) {
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  dbg(comma + 1, args...);
}
template <class T>
void read(T &x) {
  cin >> x;
}
template <class T, class... U>
void read(T &t, U &...u) {
  read(t);
  read(u...);
}
int gcd(int a, int b) { return !a ? b : gcd(b % a, a); }
struct SegTree {
  int size = 1;
  vector<int> elements, a;
  void init(int n) {
    while (size < n) size *= 2;
    elements.assign(2 * size, int(1e9 + 5));
  }
  void pull(int x) {
    elements[x] = min(elements[2 * x + 1], elements[2 * x + 2]);
  }
  void build(int x, int lx, int rx) {
    if (rx - lx == 1) {
      if (lx < (int)(a).size()) {
        elements[x] = a[lx];
      }
      return;
    }
    int mid = (lx + rx) / 2;
    build(2 * x + 1, lx, mid);
    build(2 * x + 2, mid, rx);
    pull(x);
  }
  void build(const vector<int> &x) {
    a = x;
    build(0, 0, size);
  }
  void set(int i, int v, int x, int lx, int rx) {
    if (rx - lx == 1) {
      elements[x] = v;
      return;
    }
    int mid = (lx + rx) / 2;
    if (i < mid) {
      set(i, v, 2 * x + 1, lx, mid);
    } else {
      set(i, v, 2 * x + 2, mid, rx);
    }
    pull(x);
  }
  void set(int i, int v) { set(i, v, 0, 0, size); }
  int calc(int l, int r, int x, int lx, int rx) {
    if (l >= rx or r <= lx) return int(1e9 + 5);
    if (l <= lx and rx <= r) return elements[x];
    int mid = (lx + rx) / 2;
    int r1 = calc(l, r, 2 * x + 1, lx, mid);
    int r2 = calc(l, r, 2 * x + 2, mid, rx);
    return min(r1, r2);
  }
  int calc(int l, int r) { return calc(l, r, 0, 0, size); }
};
struct SparseTableMIN {
  int size = 1;
  vector<int> v;
  vector<int> log_table;
  void makeLogTable() {
    for (auto(i) = 2; (i) < ((int)(log_table).size()); (i)++) {
      log_table[i] = log_table[i / 2] + 1;
    }
  }
  vector<vector<int> > table;
  void makeTable() {
    table.resize(log_table.back() + 1, vector<int>((int)(v).size()));
    table[0] = v;
    for (auto(row) = 1; (row) < ((int)(table).size()); (row)++) {
      const int pow2_before = 1 << (row - 1);
      const int pow2 = 1 << row;
      for (int i = 0; i + pow2 <= (int)(v).size(); i++) {
        table[row][i] = min(table[row - 1][i], table[row - 1][i + pow2_before]);
      }
    }
  }
  void init(int n, vector<int> &inp) {
    size = n;
    v.resize(n);
    for (auto(i) = 0; (i) < (n); (i)++) v[i] = inp[i];
    log_table.assign(n + 1, 0);
    makeLogTable();
    makeTable();
  }
  int calc(int l, int r) {
    int lg = log_table[r - l];
    int mnm = min(table[lg][l], table[lg][r - (1 << lg)]);
    return mnm;
  }
};
struct SparseTableMAX {
  int size = 1;
  vector<int> v;
  vector<int> log_table;
  void makeLogTable() {
    for (auto(i) = 2; (i) < ((int)(log_table).size()); (i)++) {
      log_table[i] = log_table[i / 2] + 1;
    }
  }
  vector<vector<int> > table;
  void makeTable() {
    table.resize(log_table.back() + 1, vector<int>((int)(v).size()));
    table[0] = v;
    for (auto(row) = 1; (row) < ((int)(table).size()); (row)++) {
      const int pow2_before = 1 << (row - 1);
      const int pow2 = 1 << row;
      for (int i = 0; i + pow2 <= (int)(v).size(); i++) {
        table[row][i] = max(table[row - 1][i], table[row - 1][i + pow2_before]);
      }
    }
  }
  void init(int n, vector<int> &inp) {
    size = n;
    v.resize(n);
    for (auto(i) = 0; (i) < (n); (i)++) v[i] = inp[i];
    log_table.assign(n + 1, 0);
    makeLogTable();
    makeTable();
  }
  int calc(int l, int r) {
    int lg = log_table[r - l];
    int mnm = max(table[lg][l], table[lg][r - (1 << lg)]);
    return mnm;
  }
};
int n, max_diff, min_size;
vector<int> a;
int dp[int(1e5 + 10)];
SegTree st;
SparseTableMIN st_min;
SparseTableMAX st_max;
int32_t main() {
  setIO();
  read(n, max_diff, min_size);
  read(a, n);
  st.init(n);
  st_min.init(n, a);
  st_max.init(n, a);
  auto bin = [&](int idx) {
    int lo = idx, hi = n - 1;
    int res = -1, mid, mx, mn;
    while (lo <= hi) {
      mid = (lo + hi) / 2;
      mx = st_max.calc(idx, mid + 1);
      mn = st_min.calc(idx, mid + 1);
      if (mx - mn <= max_diff) {
        res = mid;
        lo = mid + 1;
      } else {
        hi = mid - 1;
      }
    }
    return res;
  };
  dp[n - 1] = int(1e9 + 5);
  if (min_size == 1) dp[n - 1] = 1;
  st.set(n - 1, 0);
  int idx;
  for (int i = n - 2; i >= 0; i--) {
    idx = bin(i);
    st.set(i, dp[i + 1]);
    if (idx >= i + min_size - 1) {
      dp[i] = st.calc(i + min_size - 1, idx + 1) + 1;
    } else {
      dp[i] = int(1e9 + 5);
    }
  }
  if (dp[0] > n) {
    dp[0] = -1;
  }
  cout << dp[0] << '\n';
  return 0;
}

```