#include <bits/stdc++.h>
using namespace std;
template <typename T>
static ostream& operator<<(ostream& stream, const vector<T>& t);
template <typename F, typename S>
static istream& operator>>(istream& stream, pair<F, S>& t) {
  return stream >> t.first >> t.second;
}
template <typename T>
static istream& read(T, T, istream& = cin);
template <typename T>
static istream& operator>>(istream& stream, vector<T>& t) {
  return read((t).begin(), (t).end(), stream);
}
template <typename T>
static istream& read(T b, T e, istream& stream) {
  for (T it = b; it != e; ++it) stream >> *it;
  return stream;
}
struct _print {
  string sep, end;
  bool space;
  ostream& stream;
  _print(string _sep = " ", string _end = "\n", ostream& _stream = cout)
      : sep(_sep), end(_end), space(false), stream(_stream) {}
  ~_print() { stream << end; }
  template <typename T>
  _print& operator,(const T& t) {
    if (space) stream << sep;
    space = true;
    stream << t;
    return *this;
  }
};
const int K = 17;
void __() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  int L;
  cin >> L;
  int q;
  cin >> q;
  vector<pair<int int> >(queries, q);
  cin >> int >> ;
  vector<vector<int> > nxt_l(n, vector<int>(K)), nxt_r(n, vector<int>(K));
  int r = n - 1, l = 0;
  for (int i = n - 1; i >= 0; --i) {
    while (a[r] - a[i] > L) --r;
    nxt_r[i][0] = r;
    for (int j = 1; j <= K - 1; ++j)
      nxt_r[i][j] = nxt_r[nxt_r[i][j - 1]][j - 1];
  }
  for (int i = 0; i < n; ++i) {
    while (a[i] - a[l] > L) ++l;
    nxt_l[i][0] = l;
    for (int j = 1; j <= K - 1; ++j)
      nxt_l[i][j] = nxt_l[nxt_l[i][j - 1]][j - 1];
  }
  for (auto _ : queries) {
    int a, b;
    tie(a, b) = _;
    --a, --b;
    int ans = 0;
    if (a <= b) {
      for (int i = K - 1; i >= 0; --i)
        if (nxt_r[a][i] <= b) {
          a = nxt_r[a][i];
          ans += 1 << i;
        }
      if (a < b) {
        ++ans;
        assert(nxt_r[a][0] >= b);
      }
    } else {
      for (int i = K - 1; i >= 0; --i)
        if (nxt_l[a][i] >= b) {
          a = nxt_l[a][i];
          ans += 1 << i;
        }
      if (a > b) {
        ++ans;
        assert(nxt_l[a][0] <= b);
      }
    }
    _print(), ans;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);
  __();
}
