#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  int l;
  scanf("%d", &l);
  const int LOGM = 30;
  vector<vector<int>> c(n, vector<int>(LOGM, -1));
  for (int i = 0; i < n; i++) {
    c[i][0] = (int)(upper_bound(x.begin(), x.end(), x[i] + l) - x.begin()) - 1;
  }
  for (int k = 0; k < LOGM - 1; k++) {
    for (int i = 0; i < n; i++) {
      c[i][k + 1] = c[c[i][k]][k];
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    if (a > b) swap(a, b);
    int ans = 0;
    while (true) {
      auto p =
          (int)(upper_bound(c[a].begin(), c[a].end(), b) - c[a].begin()) - 1;
      a = c[a][p];
      ans += pow(2, p);
      if (a == b) break;
    }
    printf("%d\n", ans);
  }
  return 0;
}
