#include <bits/stdc++.h>
const int MAX = 1e5 + 15;
int aHotels;
int hotels[MAX];
int minJump;
int aQueries;
int farestNextHotel[MAX];
int jump[MAX];
signed main() {
  std::cin >> aHotels;
  for (int i = 0; i < aHotels; ++i) std::cin >> hotels[i];
  std::cin >> minJump;
  for (int i = 0; i < aHotels; ++i) {
    int l = i;
    int r = aHotels - 1;
    while (l <= r) {
      int m = (r - l) / 2 + l;
      if (hotels[m] - hotels[i] <= minJump)
        l = m + 1;
      else
        r = m - 1;
    }
    farestNextHotel[i] = l - 1;
  }
  std::cin >> aQueries;
  for (int i = 0; i < aQueries; ++i) {
    int city1;
    int city2;
    std::cin >> city1 >> city2;
    if (city2 > city1) {
      int swap = city1;
      city1 = city2;
      city2 = swap;
    }
    --city1;
    --city2;
    int curPlace = city2;
    int cnt = 0;
    while (curPlace < city1) {
      cnt++;
      curPlace = farestNextHotel[curPlace];
    }
    std::cout << cnt << std::endl;
  }
}
