#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) cin >> x[i];
  int l;
  cin >> l;
  int dpL[16][n];
  int dpR[16][n];
  for (int i = 0; i < n; ++i) {
    dpL[0][i] = lower_bound(x.begin(), x.end(), x[i] - l) - x.begin();
    dpR[0][i] = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
  }
  for (int k = 0; k < 15; ++k) {
    for (int i = 0; i < n; ++i) {
      dpL[k + 1][i] = dpL[k][dpL[k][i]];
      dpR[k + 1][i] = dpR[k][dpR[k][i]];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    int ans = 0;
    if (a < b) {
      int now = a;
      while (now < b) {
        if (b <= dpR[0][now]) {
          ans += 1;
          break;
        }
        for (int k = 0; k < 15; ++k) {
          if (dpR[k][now] <= b and b <= dpR[k + 1][now]) {
            now = dpR[k][now];
            ans += pow(2, k);
            break;
          }
        }
      }
    } else {
      int now = a;
      while (b < now) {
        if (dpL[0][now] <= b) {
          ans += 1;
          break;
        }
        for (int k = 0; k < 15; ++k) {
          if (dpL[k + 1][now] <= b and b <= dpL[k][now]) {
            now = dpL[k][now];
            ans += pow(2, k);
            break;
          }
        }
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
