#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main() {
  int N;
  int L;
  int p[maxn];
  int q;
  int x, y;
  while (scanf("%d", &N) != EOF) {
    for (int i = 1; i <= N; i++) {
      scanf("%d", &p[i]);
    }
    scanf("%d", &L);
    scanf("%d", &q);
    while (q--) {
      int t;
      int k;
      scanf("%d%d", &x, &y);
      int cont = 0;
      if (x < y) {
        t = x;
        while (t < y) {
          k = p[t] + L;
          if (k >= p[N]) {
            cont++;
            break;
          }
          t = upper_bound(p + 1, p + 1 + N, k) - p;
          t--;
          cont++;
        }
        printf("%d\n", cont);
      }
      if (x > y) {
        t = x;
        while (t > y) {
          k = p[t] - L;
          if (k <= p[1]) {
            cont++;
            break;
          }
          t = lower_bound(p + 1, p + 1 + N, k) - p;
          cont++;
        }
        printf("%d\n", cont);
      }
    }
    return 0;
  }
}
