#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 5;
int n, m, len, a[N], b[N], dp[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  scanf("%d%d", &len, &m);
  for (int i = n, j = n; i >= 1; --i) {
    while (j >= 1 && a[j] - a[i] > len) --j;
    b[i] = j;
    if (i != j) dp[i] = dp[j] + 1;
  }
  while (m--) {
    int from, to;
    scanf("%d%d", &from, &to);
    if (from > to) swap(from, to);
    int lo = from, hi = n, ans = -1, mid;
    while (lo <= hi) {
      mid = (lo + hi) >> 1;
      if (b[mid] >= to)
        ans = mid, hi = mid - 1;
      else
        lo = mid + 1;
    }
    printf("%d\n", dp[from] - dp[ans] + 1);
  }
  return 0;
}
