#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;
template <typename T>
void dpite(T a, T b) {
  return;
}
template <typename T>
void pite(T a, T b) {
  for (T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite;
  cout << '\n';
}
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 ios_init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
}
int maxlog(int n) {
  int res = 0;
  while (n != 0) {
    n >>= 1;
    res++;
  }
  if ((res << 1) < n) res++;
  return res;
}
int main() {
  ios_init();
  int n;
  cin >> n;
  vector<long long int> x(n);
  for (int i = (0); i < (n); ++i) cin >> x[i];
  long long int l;
  cin >> l;
  int m = maxlog(n);
  vector<vector<int>> nex(m, vector<int>(n, -1));
  for (int i = (0); i < (n); ++i) {
    auto tmp = upper_bound(x.begin() + i, x.end(), x[i] + l);
    if (tmp == x.end()) {
      nex[0][i] = n - 1;
    } else if (tmp == x.begin() + i) {
      nex[0][i] = -1;
    } else {
      tmp--;
      nex[0][i] = tmp - x.begin();
    }
  }
  for (int i = (0); i < (m - 1); ++i) {
    for (int j = (0); j < (n); ++j) {
      if (nex[i][j] == -1) nex[i + 1][j] = -1;
      nex[i + 1][j] = nex[i][nex[i][j]];
    }
  }
  for (int i = (0); i < (m); ++i) dpite((nex[i]).begin(), (nex[i]).end());
  int q;
  cin >> q;
  for (int i = (0); i < (q); ++i) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    int ans = 0;
    for (int k = (m)-1; k >= 0; k--) {
      if (nex[k][a] == -1) continue;
      if (nex[k][a] <= b) {
        a = nex[k][a];
        ans += (1 << k);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
