#include <bits/stdc++.h>
using namespace std;
int N, s, l;
int a[100005];
int maxt[3 * 100005];
int mint[3 * 100005];
int leftmostRange[100005];
int dp[100005];
int dpt[3 * 100005];
void update(int node, int a, int b, int i, int j, int val, int type) {
  if (a > b || a > j || b < i) return;
  if (a == b) {
    if (type == 0) {
      maxt[node] = val;
    } else if (type == 1) {
      mint[node] = val;
    } else {
      dpt[node] = val;
    }
    return;
  }
  update(node * 2, a, (a + b) / 2, i, j, val, type);
  update(node * 2 + 1, (a + b) / 2 + 1, b, i, j, val, type);
  if (type == 0) {
    maxt[node] = max(maxt[node * 2], maxt[node * 2 + 1]);
  } else if (type == 1) {
    mint[node] = min(mint[node * 2], mint[node * 2 + 1]);
  } else {
    dpt[node] = min(dpt[node * 2], dpt[node * 2 + 1]);
  }
}
int query(int node, int a, int b, int i, int j, int type) {
  if (a > b || a > j || b < i) {
    if (type == 0)
      return -1000000000;
    else
      return 1000000000;
  }
  if (a >= i && b <= j) {
    if (type == 0) {
      return maxt[node];
    } else if (type == 1) {
      return mint[node];
    } else {
      return dpt[node];
    }
  }
  int q1 = query(node * 2, a, (a + b) / 2, i, j, type);
  int q2 = query(node * 2 + 1, 1 + (a + b) / 2, b, i, j, type);
  if (type == 0) {
    return max(q1, q2);
  } else {
    return min(q1, q2);
  }
}
void getLefts() {
  for (int i = (1); i <= (N); i++) {
    int left = max(0, leftmostRange[i - 1] - 1), right = i;
    while (left + 1 < right) {
      int mid = (left + right) / 2;
      int maxv = query(1, 1, N, mid, i, 0);
      int minv = query(1, 1, N, mid, i, 1);
      if (maxv - minv <= s) {
        right = mid;
      } else {
        left = mid;
      }
    }
    leftmostRange[i] = right;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> s >> l;
  for (int i = (1); i <= (N); i++) {
    cin >> a[i];
    update(1, 1, N, i, i, a[i], 0);
    update(1, 1, N, i, i, a[i], 1);
  }
  getLefts();
  for (int i = (1); i <= (N); i++) {
    int left = leftmostRange[i] - 1;
    int right = i - l;
    dp[i] = query(1, 1, N, max(1, left), right, 2) + 1;
    if (left == 0 && left <= right) {
      dp[i] = min(dp[i], 1);
    }
    update(1, 1, N, i, i, dp[i], 2);
  }
  int ans = dp[N];
  if (ans > 100000) {
    cout << "-1\n";
  } else {
    cout << ans << "\n";
  }
  return 0;
}

### Prompt

Develop a solution in Cpp 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;
int N, s, l;
int a[100005];
int maxt[3 * 100005];
int mint[3 * 100005];
int leftmostRange[100005];
int dp[100005];
int dpt[3 * 100005];
void update(int node, int a, int b, int i, int j, int val, int type) {
  if (a > b || a > j || b < i) return;
  if (a == b) {
    if (type == 0) {
      maxt[node] = val;
    } else if (type == 1) {
      mint[node] = val;
    } else {
      dpt[node] = val;
    }
    return;
  }
  update(node * 2, a, (a + b) / 2, i, j, val, type);
  update(node * 2 + 1, (a + b) / 2 + 1, b, i, j, val, type);
  if (type == 0) {
    maxt[node] = max(maxt[node * 2], maxt[node * 2 + 1]);
  } else if (type == 1) {
    mint[node] = min(mint[node * 2], mint[node * 2 + 1]);
  } else {
    dpt[node] = min(dpt[node * 2], dpt[node * 2 + 1]);
  }
}
int query(int node, int a, int b, int i, int j, int type) {
  if (a > b || a > j || b < i) {
    if (type == 0)
      return -1000000000;
    else
      return 1000000000;
  }
  if (a >= i && b <= j) {
    if (type == 0) {
      return maxt[node];
    } else if (type == 1) {
      return mint[node];
    } else {
      return dpt[node];
    }
  }
  int q1 = query(node * 2, a, (a + b) / 2, i, j, type);
  int q2 = query(node * 2 + 1, 1 + (a + b) / 2, b, i, j, type);
  if (type == 0) {
    return max(q1, q2);
  } else {
    return min(q1, q2);
  }
}
void getLefts() {
  for (int i = (1); i <= (N); i++) {
    int left = max(0, leftmostRange[i - 1] - 1), right = i;
    while (left + 1 < right) {
      int mid = (left + right) / 2;
      int maxv = query(1, 1, N, mid, i, 0);
      int minv = query(1, 1, N, mid, i, 1);
      if (maxv - minv <= s) {
        right = mid;
      } else {
        left = mid;
      }
    }
    leftmostRange[i] = right;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> s >> l;
  for (int i = (1); i <= (N); i++) {
    cin >> a[i];
    update(1, 1, N, i, i, a[i], 0);
    update(1, 1, N, i, i, a[i], 1);
  }
  getLefts();
  for (int i = (1); i <= (N); i++) {
    int left = leftmostRange[i] - 1;
    int right = i - l;
    dp[i] = query(1, 1, N, max(1, left), right, 2) + 1;
    if (left == 0 && left <= right) {
      dp[i] = min(dp[i], 1);
    }
    update(1, 1, N, i, i, dp[i], 2);
  }
  int ans = dp[N];
  if (ans > 100000) {
    cout << "-1\n";
  } else {
    cout << ans << "\n";
  }
  return 0;
}

```