#include <bits/stdc++.h>
int main(void) {
  int x[100000];
  int y[100000];
  int n;
  int q;
  int l;
  int o;
  int p;
  int a, b, c;
  int z;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  scanf("%d", &l);
  scanf("%d", &q);
  o = 0;
  p = 0;
  for (; o < n;) {
    if (p == n) {
      y[o] = p - 1;
      o++;
    } else if (x[o] + l < x[p]) {
      y[o] = p - 1;
      o++;
    } else {
      p++;
    }
  }
  for (int qq = 0; qq < q; qq++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    if (a > b) {
      z = b;
      b = a;
      a = z;
    }
    c = 0;
    z = a;
    for (; z < b;) {
      z = y[z];
      c++;
    }
    printf("%d\n", c);
  }
  return 0;
}
