#include <bits/stdc++.h>
using namespace std;
int n, a[111111], spre[111111], snxt[111111], bpre[111111], bnxt[111111], l, q,
    pos, j;
int numpre[111111], numnxt[111111], cnt, x, y;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d%d", &l, &q);
  for (int i = 1; i <= n; i++) {
    snxt[i] = lower_bound(a + 1, a + n + 1, a[i] + l + 1) - a - 1;
    spre[i] = lower_bound(a + 1, a + n + 1, a[i] - l) - a;
  }
  for (int i = 1; i <= n; i++) {
    pos = i;
    for (j = 0; j < 300; j++) {
      if (pos == 1) break;
      pos = spre[pos];
    }
    bpre[i] = pos;
    numpre[i] = j;
    pos = i;
    for (j = 0; j < 300; j++) {
      if (pos == n) break;
      pos = snxt[pos];
    }
    numnxt[i] = j;
    bnxt[i] = pos;
  }
  while (q--) {
    scanf("%d%d", &x, &y);
    pos = x;
    cnt = 0;
    if (x < y) {
      while (bnxt[pos] <= y) {
        cnt += numnxt[pos];
        pos = bnxt[pos];
      }
      while (pos < y) {
        pos = snxt[pos];
        cnt++;
      }
    } else {
      while (bpre[pos] >= y) {
        cnt += numpre[pos];
        pos = bpre[pos];
      }
      while (pos > y) {
        pos = spre[pos];
        cnt++;
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}
