#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &i : v) is >> i;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, vector<T> &v) {
  const string delimiter = "\n";
  for (int i = (int)(0); i < (int)(v.size()); i++) {
    os << v[i];
    if (i != v.size() - 1) os << delimiter;
  }
  return os;
}
int main() {
  cin.sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, l;
  cin >> n;
  vector<int> x(n);
  cin >> x >> l;
  vector<vector<int> > right(n, vector<int>(18, n)),
      left(n, vector<int>(18, -1));
  for (int i = (int)(0); i < (int)(n); i++) {
    int lb = i + 1, ub = n;
    while (ub - lb > 1) {
      int mid = (ub + lb) / 2;
      if (x[mid] - x[i] > l)
        ub = mid;
      else
        lb = mid;
    }
    right[i][0] = lb;
  }
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(17); j++) {
      if (right[i][j] == n)
        right[i][j + 1] = n;
      else
        right[i][j + 1] = right[right[i][j]][j];
    }
  }
  for (int i = (int)(0); i < (int)(n); i++) {
    int lb = i - 1, ub = -1;
    while (lb - ub > 1) {
      int mid = (ub + lb) / 2;
      if (x[i] - x[mid] > l)
        ub = mid;
      else
        lb = mid;
    }
    left[i][0] = lb;
  }
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(17); j++) {
      if (left[i][j] == -1)
        left[i][j + 1] = -1;
      else
        left[i][j + 1] = left[left[i][j]][j];
    }
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int ans = 0;
    if (a < b) {
      int t = a;
      while (t < b) {
        for (int i = 17; i >= 0; i--) {
          if (i == 0) {
            ans += 1;
            t = right[t][i];
          } else {
            if (right[t][i] <= b) {
              ans += 1 << i;
              t = right[t][i];
              break;
            }
          }
        }
      }
    } else {
      int t = a;
      while (t > b) {
        for (int i = 17; i >= 0; i--) {
          if (i == 0) {
            ans += 1;
            t = left[t][i];
          } else {
            if (left[t][i] >= b) {
              ans += 1 << i;
              t = left[t][i];
              break;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
