#include <bits/stdc++.h>
using namespace std;
template <typename UnaryPredicate>
int64_t binsearch_max(int64_t l, int64_t r, UnaryPredicate p) {
  assert(l <= r);
  ++r;
  while (r - l > 1) {
    int64_t m = l + (r - l) / 2;
    (p(m) ? l : r) = m;
  }
  return l;
}
struct doubling_table {
  vector<vector<int> > table;
  doubling_table() = default;
  doubling_table(vector<int> const& next, int size = -1) {
    int n = next.size();
    {
      auto it = minmax_element(begin(next), end(next));
      assert(0 <= *(it.first) and *(it.second) <= n);
    }
    if (size == -1) {
      size = max<int>(1, ceil(log2(n)));
    }
    table.resize(size);
    table[0] = next;
    for (int k = 0; (k) < int(size - 1); ++(k)) {
      table[k + 1].resize(n, n);
      for (int i = 0; (i) < int(n); ++(i))
        if (table[k][i] != n) {
          table[k + 1][i] = table[k][table[k][i]];
        }
    }
  }
};
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; (i) < int(n); ++(i)) scanf("%d", &a[i]);
  int l;
  scanf("%d", &l);
  vector<int> next(n);
  for (int i = 0; (i) < int(n); ++(i)) {
    next[i] = binsearch_max(i, n - 1, [&](int j) { return a[j] - a[i] <= l; });
  }
  doubling_table doubling(next);
  int queries;
  scanf("%d", &queries);
  while (queries--) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    if (a > b) swap(a, b);
    int result = 0;
    for (int k = 0; (k) < int(doubling.table.size()); ++(k)) {
      if (doubling.table[k][a] < b) {
        a = doubling.table[k][a];
        result += 1 << k;
      }
    }
    while (a < b) {
      a = next[a];
      result += 1;
    }
    printf("%d\n", result);
  }
  return 0;
}
