#include <bits/stdc++.h>
using namespace std;
int x[100010], fa[100010][20], step[100010];
vector<int> G[100010];
void dfs(int u, int p) {
  step[u] = step[p] + 1;
  for (int i = 1, j = 2; j < step[u]; i++, j <<= 1)
    fa[u][i] = fa[fa[u][i - 1]][i - 1];
  for (int i = 0; i < G[u].size(); i++) dfs(G[u][i], u);
}
int Solve(int a, int b) {
  if (a > b) swap(a, b);
  int d = step[a] - step[b];
  int ret = 0;
  for (int i = 0; (1 << i) <= d; i++)
    if (d & (1 << i)) a = fa[a][i];
  if (a >= b)
    return d;
  else if (a < b)
    return d + 1;
}
int main() {
  int n, L, q, a, b;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  scanf("%d", &L);
  int l = 1, r = 1;
  while (l < n) {
    while (r <= n && x[r] - x[l] <= L) r++;
    fa[l][0] = r - 1;
    G[r - 1].push_back(l);
    l++;
  }
  dfs(n, 0);
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &a, &b);
    printf("%d\n", Solve(a, b));
  }
}
