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

 public:
  Hotels(int N, int L, const vector<int>& hotels) : dp(N) {
    for (int i = 0; i < N; i++) {
      int k = binary_search(hotels, hotels[i] + L);
      if (k == N) k--;
      dp[i].push_back(k);
    }
    for (int k = 1; dp[0].back() != N - 1; k++) {
      for (int i = 0; i < N; i++)
        if (dp[i].back() == N - 1)
          break;
        else
          dp[i].push_back(k - 1 < dp[i].size() &&
                                  k - 1 < dp[dp[i][k - 1]].size()
                              ? dp[dp[i][k - 1]][k - 1]
                              : N - 1);
    }
  }
  int query(int a, int b) {
    a--, b--;
    if (a > b) swap(a, b);
    int cur = a, res = 0;
    while (cur != b) {
      int k = binary_search(dp[cur], b);
      res += (1 << k);
      cur = dp[cur][k];
    }
    return res;
  }

 private:
  int binary_search(const vector<int>& v, int target) {
    int l = 0, r = v.size();
    while (l < r) {
      int mid = (l + r + 1) / 2;
      if (v[mid] > target)
        r = mid - 1;
      else
        l = mid;
    }
    return l;
  }
};
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;
}
