#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long POWER[65];
long long power(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret *= a;
    a *= a;
    if (ret >= MOD) ret %= MOD;
    if (a >= MOD) a %= MOD;
    b >>= 1;
  }
  return ret;
}
long long inv(long long x) { return power(x, MOD - 2); }
void precompute() {
  POWER[0] = 1;
  for (int i = 1; i < 63; i++) POWER[i] = POWER[i - 1] << 1LL;
}
const int MAXN = 1e5 + 5;
int x[MAXN];
int ending[MAXN];
int answer[MAXN];
int l;
int bs(int lo, int hi, int cur) {
  int ret = -1;
  while (lo <= hi) {
    int mid = lo + (hi - lo + 1) / 2;
    if (x[mid] - x[cur] <= l)
      ret = mid, lo = mid + 1;
    else
      hi = mid - 1;
  }
  return ret;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  int BLOCK = sqrt(n);
  cin >> l;
  for (int i = 1; i <= n; i++) {
    int st = i, en = i + BLOCK;
    if (i + BLOCK > n) break;
    int ans = 0;
    while (st < en) {
      int idx = bs(st + 1, n, st);
      ans++;
      if (idx >= en)
        st = en, ending[i] = idx;
      else
        st = idx;
    }
    answer[i] = ans;
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    if (a + BLOCK == b) {
      printf("%d\n", answer[a]);
      continue;
    } else if (a + BLOCK > b) {
      int st = a, en = b;
      int ans = 0;
      while (st < en) {
        int idx = bs(st + 1, n, st);
        ans++;
        if (idx >= en)
          st = en;
        else
          st = idx;
      }
      printf("%d\n", ans);
      continue;
    } else {
      int ans = 0;
      while (a + BLOCK < b) {
        ans += answer[a];
        a = ending[a];
      }
      while (a < b) {
        int idx = bs(a + 1, n, a);
        ans++;
        if (idx >= b)
          a = b;
        else
          a = idx;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
