#include <bits/stdc++.h>
using namespace std;
class Hotels {
 private:
  int N, L;
  vector<int>& hotels;

 public:
  Hotels(int N, int L, vector<int>& hotels) : N(N), L(L), hotels(hotels) {}
  int query(int a, int b) {
    int d = 0, cur = a;
    while (cur < b) {
      vector<int>::iterator iter =
          lower_bound(hotels.begin() + a, hotels.end(), hotels[cur] + L);
      if (iter == hotels.end() || *iter > hotels[cur] + L) iter--;
      cur = iter - hotels.begin();
      d++;
    }
    return d;
  }
};
int main() {
  int N;
  scanf("%d", &N);
  vector<int> hotels(N);
  for (int i = 0; i < N; i++) scanf("%d", &hotels[i]);
  int L;
  scanf("%d", &L);
  Hotels h(N, L, hotels);
  int Q, a, b;
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    printf("%d\n", h.query(a - 1, b - 1));
  }
  return 0;
}
