#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using f64 = double_t;
using str = string;
template <typename T>
using vec = vector<T>;
template <typename T>
using heap = priority_queue<T, vec<T>, greater<T>>;
const i64 MOD = 1000000007;
i32 n, x[100000], l, q, a[100000], b[100000];
i32 d[100000], e[100000];
i32 main() {
  cin >> n;
  for (i32 i = 0; i < (n); ++i) {
    cin >> x[i];
  }
  cin >> l >> q;
  for (i32 i = 0; i < (q); ++i) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  if (n > 1000 || q > 1000) return 0;
  for (i32 i = 0; i < (n - 1); ++i) {
    for (i32 j = (i + 1); j < (n); ++j) {
      if (x[j] - x[i] <= l)
        d[i] = j;
      else
        break;
    }
  }
  for (i32 i = (n); i >= (1); --i) {
    for (i32 j = (i - 1); j >= (0); --j) {
      if (x[i] - x[j] <= l)
        e[i] = j;
      else
        break;
    }
  }
  for (i32 i = 0; i < (q); ++i) {
    if (a[i] < b[i]) {
      i32 ans = 0, p = a[i];
      while (p < b[i]) {
        p = d[p];
        ans++;
      }
      cout << ans << endl;
    } else {
      i32 ans = 0, p = a[i];
      while (p > b[i]) {
        p = e[p];
        ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}
