#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  int l;
  cin >> l;
  int next[2][n][20];
  memset(next, -1, sizeof(next));
  for (int i = 0; i < n - 1; i++) {
    int left = i;
    int right = n;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (x[mid] - x[i] <= l)
        left = mid;
      else
        right = mid;
    }
    next[0][i][0] = left;
    cout << i << " " << left << endl;
  }
  for (int i = 1; i < n; i++) {
    int left = -1;
    int right = i;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (x[i] - x[mid] <= l)
        right = mid;
      else
        left = mid;
    }
    next[1][i][0] = right;
    cout << i << " " << right << endl;
  }
  for (int c = 1; c < 20; c++) {
    for (int u = 0; u < 2; u++) {
      for (int i = 0; i < n - 1; i++) {
        next[u][i][c] = -1;
        if (next[u][i][c - 1] == -1) continue;
        next[u][i][c] = next[u][next[u][i][c - 1]][c - 1];
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int u = !(a < b);
    int left = 0;
    int right = n;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      int curr = a;
      for (int i = 19; i >= 0; i--) {
        if (mid & (1 << i)) {
          curr = next[u][curr][i];
        }
        if (curr == -1) break;
      }
      if (curr == -1)
        right = mid;
      else {
        if (!u && curr >= b)
          right = mid;
        else if (u && curr <= b)
          right = mid;
        else
          left = mid;
      }
    }
    cout << right << endl;
  }
}
