#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 50;
const int INF = 0x3f3f3f;
int num[N];
int main() {
  int n;
  long long l;
  int q, a, b;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", num + i);
  scanf("%lld%d", &l, &q);
  while (q--) {
    int sum = 0;
    scanf("%d%d", &a, &b);
    int x = min(a, b);
    int endd = max(a, b);
    while (x != endd) {
      int cnt = num[x] + l;
      for (int i = x;; i++) {
        if (cnt < num[i]) {
          x = i - 1;
          sum++;
          break;
        }
      }
    }
    printf("%d\n", sum);
  }
  return 0;
}
