#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 77;
const int D = 18;
int n, m, L;
int x[N];
int depth[N];
int par[D + 1][N];
vector<int> g[N];
int walk(int node, int jump) {
  for (int d = 0; d <= D and node != -1; d++) {
    if ((1 << d) & jump) node = par[d][node];
  }
  return node;
}
int lca(int u, int v) {
  if (depth[u] > depth[v]) u = walk(u, depth[u] - depth[v]);
  if (depth[u] < depth[v]) v = walk(v, depth[v] - depth[u]);
  if (u == v) return u;
  for (int d = D; d >= 0; d--) {
    if (par[d][u] != par[d][v]) {
      u = par[d][u];
      v = par[d][v];
    }
  }
  return par[0][u];
}
int dist(int u, int v) { return depth[u] + depth[v] - 2 * depth[lca(u, v)]; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= (int)(n); ++i) cin >> x[i];
  cin >> L;
  memset(par, -1, sizeof par);
  int j = 1;
  for (int i = 1; i <= n; i++) {
    while (x[j] - x[i] <= L and j <= n) j++;
    par[0][i] = j - 1;
  }
  for (int d = 1; d <= D; d++) {
    for (int i = 1; i <= n; i++) {
      int jump = par[d - 1][i];
      if (jump != -1) par[d][i] = par[d - 1][jump];
    }
  }
  cin >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    int ans = 0;
    for (int d = 0; d <= D; d++) {
      if (par[d][a] != -1 and a < b) {
        a = par[d][a];
        ans += d;
      }
    }
    cout << ans + 1 << endl;
  }
  return 0;
}
