#include <bits/stdc++.h>
using namespace std;
long long ______________________________________;
long long kokoropyonpyonmatchi[100000];
long long kangaerufurisite[100001];
long long l;
long long q;
long long mutyotthikaduityaeeeeeeeeee, thikaduityaeeeeeeeeee;
long long unkonokoun[20][100000];
long long nyanyanyanyanyanyanyanyanyanya[20][100000];
long long dist(long long l, long long r) {
  if (l > r) swap(l, r);
  return kokoropyonpyonmatchi[r] - kokoropyonpyonmatchi[l];
}
bool checkL(long long mid) {
  long long i = 19;
  long long pos = mutyotthikaduityaeeeeeeeeee;
  while (i >= 0) {
    if ((mid >> i) % 2 == 1) pos = nyanyanyanyanyanyanyanyanyanya[i][pos];
    i--;
  }
  return (pos <= thikaduityaeeeeeeeeee);
}
bool checkR(long long mid) {
  long long i = 19;
  long long pos = mutyotthikaduityaeeeeeeeeee;
  while (i >= 0) {
    if ((mid >> i) % 2 == 1) pos = unkonokoun[i][pos];
    i--;
  }
  return (pos >= thikaduityaeeeeeeeeee);
}
bool check(long long mid) {
  if (mutyotthikaduityaeeeeeeeeee >= thikaduityaeeeeeeeeee) return checkL(mid);
  return checkR(mid);
}
signed main() {
  long long i, j;
  cin >> ______________________________________;
  for (i = 0; i < ______________________________________; i++)
    cin >> kokoropyonpyonmatchi[i];
  cin >> l;
  j = 0;
  for (i = 0; i < ______________________________________; i++) {
    for (j = max(j, i);
         j < ______________________________________ && dist(i, j) <= l; j++)
      ;
    j--;
    unkonokoun[0][i] = j;
  }
  for (i = 1; i < 20; i++) {
    for (j = 0; j < ______________________________________; j++) {
      unkonokoun[i][j] = unkonokoun[i - 1][unkonokoun[i - 1][j]];
    }
  }
  j = ______________________________________ - 1;
  for (i = ______________________________________ - 1; i >= 0; i--) {
    for (j = min(j, i); j >= 0 && dist(i, j) <= l; j--)
      ;
    j++;
    nyanyanyanyanyanyanyanyanyanya[0][i] = j;
  }
  for (i = 1; i < 20; i++) {
    for (j = 0; j < ______________________________________; j++) {
      nyanyanyanyanyanyanyanyanyanya[i][j] = nyanyanyanyanyanyanyanyanyanya
          [i - 1][nyanyanyanyanyanyanyanyanyanya[i - 1][j]];
    }
  }
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> mutyotthikaduityaeeeeeeeeee >> thikaduityaeeeeeeeeee;
    mutyotthikaduityaeeeeeeeeee--;
    thikaduityaeeeeeeeeee--;
    long long stastasta = 0,
              toritter = ______________________________________ + 5, mendou;
    while (toritter - stastasta >= 2) {
      mendou = (stastasta + toritter) / 2;
      if (check(mendou)) {
        toritter = mendou;
      } else {
        stastasta = mendou;
      }
    }
    cout << toritter << endl;
  }
  return 0;
}
