#include <bits/stdc++.h>
int p2[30];
int next[100010][30] = {0};
int x[100010];
void init(void) {
  p2[0] = 1;
  for (int i = 1; i <= 20; i++) p2[i] = p2[i - 1] * 2;
}
int main(void) {
  init();
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", x + i);
  }
  int l;
  scanf("%d", &l);
  int p = 1;
  for (int i = 1; i <= n; i++) {
    for (; p <= n && x[i] + l >= x[p]; p++)
      ;
    next[i][0] = p - 1;
  }
  for (int j = 1; j <= 20; j++) {
    for (int i = 1; i <= n; i++) next[i][j] = next[next[i][j - 1]][j - 1];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) std::swap(a, b);
    int ans = 0;
    while (a < b) {
      int j;
      for (j = 1; next[a][j] > 0 && next[a][j] <= b; j++)
        ;
      a = next[a][j - 1];
      ans += p2[j - 1];
    }
    printf("%d\n", ans);
  }
}
