#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(n - 1, -1, 0);
  for (int(j) = 0; (j) < 19; j++)
    for (int(i) = 0; (i) < n; i++)
      if (p[i][j] != -1)
        p[i][j + 1] = p[p[i][j]][j];
      else
        p[i][j + 1] = -1;
}
int up(int u, int dis) {
  for (int i = 19; i >= 0; i--)
    if (dis & (1 << i)) {
      if (p[u][i] == -1) return 1e9;
      u = p[u][i];
    }
  return u;
}
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--;
    if (u > v) swap(u, v);
    int l = 0, r = n;
    while (r - l > 1) {
      int mid = (l + r) >> 1;
      int cur = up(u, mid);
      if (cur > v)
        r = mid;
      else
        l = mid;
    }
    printf("%d\n", l);
  }
  return 0;
}
