#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int pos[100005];
int par[100005];
vector<int> G[100005];
int dfn[100005], dep[100005], tot;
void dfs(int v, int cd) {
  dep[v] = cd;
  dfn[v] = tot++;
  for (int i = 0; i < (int)(G[v].size()); i++) dfs(G[v][i], cd + 1);
}
int main() {
  int n, l, q;
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); i++) scanf("%d", &pos[i]);
  scanf("%d%d", &l, &q);
  int rp = 0;
  for (int i = 0; i < (int)(n - 1); i++) {
    while (rp < n && pos[rp] - pos[i] <= l) rp++;
    par[i] = rp - 1;
  }
  for (int i = 0; i < (int)(n - 1); i++) G[par[i]].push_back(i);
  dfs(n - 1, 0);
  for (int i = 0; i < (int)(q); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = dep[a] - dep[b];
    if (dfn[a] < dfn[b]) ans++;
    printf("%d\n", ans);
  }
  return 0;
}
