#include <bits/stdc++.h>
using namespace std;
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long long MXLL = 4e18;
const int Sz = 1110111;
inline void Read_rap() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
inline void randomizer3000() {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
void files(string problem) {
  if (fopen((problem + ".in").c_str(), "r")) {
    freopen((problem + ".in").c_str(), "r", stdin);
    freopen((problem + ".out").c_str(), "w", stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen(in, "r")) {
    freopen(in, "r", stdin);
  } else
    cerr << "Warning: Input file not found" << endl;
}
int n;
int L;
int first[Sz];
const int N = 1e5 + 1;
int nxt[18][N];
int main() {
  Read_rap();
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> first[i];
  cin >> L;
  for (int i = n; i >= 1; i--) {
    static int ptr = n;
    while (first[ptr] - first[i] > L) ptr--;
    nxt[0][i] = ptr;
    for (int j = 1; i + (1 << j) - 1 <= n; j++)
      nxt[j][i] = nxt[j - 1][nxt[j - 1][i]];
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    if (l > r) swap(l, r);
    int ans = 0;
    for (int i = 17; i >= 0; i--) {
      if (nxt[i][l] && nxt[i][l] <= r) l = nxt[i][l], ans += (1 << i);
    }
    cout << ans << endl;
  }
  return 0;
}
