#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e5;
int n, A[MAXN + 5], l, t;
int LOWER_BOUND(int x) {
  int l = 1, r = n;
  while (l + 1 < r) {
    int mid = (l + r) >> 1;
    if (A[mid] <= x)
      l = mid;
    else
      r = mid;
  }
  return l;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  scanf("%d%d", &l, &t);
  while (t--) {
    int start, over;
    scanf("%d%d", &start, &over);
    if (start > over) swap(start, over);
    int x = start, ans = 0;
    while (x < over) ans++, x = LOWER_BOUND(A[x] + l);
    printf("%d\n", ans);
  }
  return 0;
}
