#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, x, q;
int a[maxn], dep[maxn], p[maxn][20];
vector<int> edge[maxn];
void dfs(int x, int par, int depth) {
  p[x][0] = par;
  dep[x] = depth;
  for (int(i) = 0; (i) < edge[x].size(); i++) {
    int y = edge[x][i];
    if (y != par) dfs(y, x, depth + 1);
  }
}
void get_p() {
  dfs(0, -1, 0);
  for (int(i) = 0; (i) < n; i++)
    for (int(j) = 0; (j) < 19; j++) p[i][j + 1] = p[p[i][j]][j];
}
int LCA(int u, int v) {
  int res = 0;
  if (dep[u] < dep[v]) swap(u, v);
  int diff = dep[u] - dep[v];
  for (int i = 19; i >= 0; i--)
    if (diff & (1 << i)) {
      u = p[u][i];
      res += (1 << i);
    }
  if (u == v) return res;
  for (int i = 19; i >= 0; i--) {
    if (p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
      res += (1 << i) * 2;
    }
  }
  return res + 2;
}
int main() {
  scanf("%d", &n);
  for (int(i) = 0; (i) < n; i++) scanf("%d", &a[i]);
  scanf("%d", &x);
  for (int(i) = 0; (i) < n - 1; i++) {
    int cur = a[i] + x;
    int pos = upper_bound(a, a + n, cur) - a - 1;
    edge[i].push_back(pos);
    edge[pos].push_back(i);
  }
  get_p();
  scanf("%d", &q);
  while (q--) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    printf("%d\n", LCA(u, v));
  }
  return 0;
}
