#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& in, vector<T>& a) {
  for (auto& i : a) in >> i;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <typename T, typename U>
void chkmin(T& a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
void chkmax(T& a, U b) {
  if (a < b) a = b;
}
const int LOGN = 25;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  int l;
  cin >> l;
  vector<vector<int>> right(n, vector<int>(LOGN));
  for (int i = (int)0; i < (int)n; i++)
    right[i][0] = --upper_bound((a).begin(), (a).end(), a[i] + l) - a.begin();
  for (int i = n - 1; i >= 0; --i)
    for (int j = (int)1; j < (int)LOGN; j++)
      right[i][j] = right[right[i][j - 1]][j - 1];
  int q;
  cin >> q;
  while (q-- > 0) {
    int l, r;
    cin >> l >> r, --l, --r;
    if (l > r) swap(l, r);
    int ans = 0;
    for (int i = LOGN - 1; i >= 0; --i) {
      if (right[l][i] <= r) {
        ans += (1 << i);
        l = right[l][i];
      }
    }
    if (false) cerr << l << " ";
    cout << ans << "\n";
  }
  return 0;
}
