#include <bits/stdc++.h>
using namespace std;
void makeDoubling(vector<vector<int> >& doubling, vector<int>& x, int l,
                  bool R) {
  for (size_t i = 0; i < doubling.size(); i++)
    doubling[i][0] = (R ? (upper_bound(x.begin(), x.end(), x[i] + l) - 1)
                        : lower_bound(x.begin(), x.end(), x[i] - l)) -
                     x.begin();
  for (size_t j = 1; j < doubling[0].size(); j++)
    for (size_t i = 0; i < doubling.size(); i++)
      doubling[i][j] = doubling[doubling[i][j - 1]][j - 1];
  int limit = R ? doubling.size() - 1 : 0;
  int sentinel = R ? doubling.size() : -1;
  for (size_t i = 0; i < doubling.size(); i++)
    for (size_t j = doubling[i].size() - 1; j > 0; j--)
      if (doubling[i][j - 1] == limit && doubling[i][j] == limit)
        doubling[i][j] = sentinel;
  return;
}
int query(vector<vector<int> >& doubling, int a, int b, bool R) {
  int ans = 0;
  while (true) {
    int tmp = -1;
    if (R)
      while (doubling[a][tmp + 1] <= b) ++tmp;
    else
      while (doubling[a][tmp + 1] >= b) ++tmp;
    if (tmp == -1) {
      return ans + 1;
    }
    ans += 1 << tmp;
    if (doubling[a][tmp] == b) {
      return ans;
    }
    a = doubling[a][tmp];
  }
}
int main(void) {
  int n, l;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  cin >> l;
  vector<vector<int> > doublingR(n, vector<int>(20));
  vector<vector<int> > doublingL(n, vector<int>(20));
  makeDoubling(doublingR, x, l, true);
  makeDoubling(doublingL, x, l, false);
  int q, a, b;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    --a;
    --b;
    int ans =
        (a < b) ? query(doublingR, a, b, true) : query(doublingL, a, b, false);
    cout << ans << endl;
  }
  return 0;
}
