#include <bits/stdc++.h>
using namespace std;
const double EPS = (double)1e-9;
const double PI = (double)acos(-1.0);
int irand(int lo, int hi) {
  return (((double)rand()) / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo;
}
string toString(long long x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
long long toNumber(string S) {
  long long ret;
  sscanf(S.c_str(), "%lld", &ret);
  return ret;
}
const int INF = (int)2e9;
const long long MOD = (long long)1e9 + 7;
const int N = (int)1e5;
const int DEP = 17;
int dat[N + 5];
int tab[N + 5][DEP + 1];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i += 1) scanf("%d", dat + i);
  dat[n + 1] = (int)2e9 + 10;
  int l;
  scanf("%d", &l);
  for (int i = 1, j = 1; i <= n; i++) {
    for (; dat[j] - dat[i] <= l; j++)
      ;
    tab[i][0] = j - 1;
  }
  for (int j = 1; j <= DEP; j += 1)
    for (int i = 1; i <= n; i += 1) tab[i][j] = tab[tab[i][j - 1]][j - 1];
  int q;
  scanf("%d", &q);
  for (int xxx = 0; xxx < q; xxx++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a > b) swap(a, b);
    int res = 0;
    for (int j = DEP; j >= 0; j -= 1) {
      if (tab[a][j] <= b) {
        res += 1 << j;
        if ((a = tab[a][j]) == b) break;
      }
    }
    res += (a != b);
    printf("%d\n", res);
  }
  return 0;
}
