#include <bits/stdc++.h>
using namespace std;
const int N = 100002;
int n, L, q, x[N], i, j, k, a, b, l, r;
int h[N], t[N], v[N], Ans[N];
int dep[N], p[N];
struct Uzi {
  int d, id;
};
vector<Uzi> g[N];
void add(int a, int b) {
  t[++k] = h[a];
  h[a] = k;
  v[k] = b;
}
void init() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", x + i);
  scanf("%d", &L);
  for (l = r = 1; l < n; l++) {
    while (r < n && x[r + 1] - x[l] <= L) r++;
    add(r, l);
  }
}
void dfs(int i) {
  p[dep[i]] = i;
  for (int j = 0; j < g[i].size(); j++)
    if (p[dep[g[i][j].d]] <= g[i][j].d)
      Ans[g[i][j].id] = dep[i] - dep[g[i][j].d];
    else
      Ans[g[i][j].id] = dep[i] - dep[g[i][j].d] + 1;
  for (int j = h[i]; j; j = t[j]) {
    dep[v[j]] = dep[i] + 1;
    dfs(v[j]);
  }
}
void work() {
  scanf("%d", &q);
  for (i = 1; i <= q; i++) {
    scanf("%d%d", &a, &b);
    if (a > b) a ^= b ^= a ^= b;
    g[a].push_back((Uzi){b, i});
  }
  dfs(n);
  for (i = 1; i <= q; i++) printf("%d\n", Ans[i]);
}
int main() {
  init();
  work();
  return 0;
}
