#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 998244353;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
namespace {
template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
template <typename T>
void Cout(const T& x, const char* end = "\n") {
  std::cout << x << end;
}
template <typename T>
void Cout(const std::vector<T>& x, const char* sep = " ",
          const char* end = "\n") {
  for (std::size_t i = 0, sz = x.size(); i < sz; ++i) {
    std::cout << x[i] << (i == sz - 1 ? end : sep);
  }
}
struct inp {
  std::size_t szi, szj;
  inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
  template <typename T>
  operator T() const {
    T a;
    std::cin >> a;
    return a;
  }
  template <typename T>
  operator std::vector<T>() const {
    std::vector<T> a(szi);
    for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i];
    return a;
  }
  template <typename T>
  operator std::vector<std::vector<T>>() const {
    std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
    for (std::size_t i = 0; i < szi; ++i)
      for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
    return a;
  }
};
inp inp1;
}  // namespace
int main() {
  int n = inp1;
  vector<ll> x = inp(n);
  ll l = inp1;
  int q = inp1;
  vector<int> a(q), b(q);
  for (ll i = 0; i < q; ++i) cin >> a[i] >> b[i], --a[i], --b[i];
  vector<pair<int, int>> next(n);
  for (ll i = 0; i < n; ++i) {
    ll from, to;
    from = x[i] - l;
    to = x[i] + l;
    next[i].first = lower_bound((x).begin(), (x).end(), from) - x.begin();
    next[i].second = upper_bound((x).begin(), (x).end(), to) - x.begin() - 1;
    chmax(next[i].second, 0);
  }
  vector<vector<int>> dpr(n, vector<int>(62, 0));
  for (ll i = 0; i < n; ++i) dpr[i][0] = next[i].second;
  for (ll j = 0; j < 61; ++j) {
    for (ll i = 0; i < n; ++i) {
      dpr[i][j + 1] = dpr[dpr[i][j]][j];
    }
  }
  vector<vector<int>> dpl(n, vector<int>(62, 0));
  for (ll i = 0; i < n; ++i) dpl[i][0] = next[i].first;
  for (ll j = 0; j < 61; ++j) {
    for (ll i = 0; i < n; ++i) {
      dpl[i][j + 1] = dpl[dpl[i][j]][j];
    }
  }
  for (ll i = 0; i < q; ++i) {
    int goal = b[i];
    bool positive = (b[i] - a[i] >= 0);
    int left = 0;
    int right = n;
    while (right - left > 1) {
      int mid = (right + left) / 2;
      int cur = a[i];
      int cnt = 0;
      int mask = 1;
      if (positive) {
        while (mask <= mid) {
          if (mask && mid) cur = dpr[cur][cnt];
          ++cnt;
          mask <<= 1;
        }
        if (cur >= goal)
          right = mid;
        else
          left = mid;
      } else {
        while (mask <= mid) {
          if (mask && mid) cur = dpl[cur][cnt];
          ++cnt;
          mask <<= 1;
        }
        if (cur <= goal)
          right = mid;
        else
          left = mid;
      }
    }
    Cout(left + 1);
  }
  return 0;
}
