#include <bits/stdc++.h>
using namespace std;
class Hotels {
 private:
  vector<vector<int>> dp;

 public:
  Hotels(int N, int L, vector<int>& hotels) : dp(N) {
    for (int i = 0; i < N; i++) {
      vector<int>::iterator iter =
          lower_bound(hotels.begin() + i, hotels.end(), hotels[i] + L);
      if (iter == hotels.end())
        dp[i].push_back(N - 1);
      else {
        if (*iter > hotels[i] + L) iter--;
        dp[i].push_back(iter - hotels.begin());
      }
    }
    for (int k = 1; dp[0].back() != N - 1; k++) {
      for (int i = 0; i < N; i++) dp[i].push_back(dp[dp[i][k - 1]][k - 1]);
    }
  }
  int query(int a, int b) {
    a--, b--;
    if (a > b) swap(a, b);
    int cur = a, res = 0;
    while (cur != b) {
      vector<int>::iterator iter =
          lower_bound(dp[cur].begin(), dp[cur].end(), b);
      if (*iter > b) iter--;
      int k = iter - dp[cur].begin();
      res += (1 << k);
      cur = dp[cur][k];
    }
    return res;
  }
};
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);
    printf("%d\n", h.query(a, b));
  }
  return 0;
}
