#include <bits/stdc++.h>
using namespace std;
int n;
int l;
int q;
vector<int> x;
vector<int> ra;
vector<int> la;
int main() {
  cin >> n;
  x.resize(n, 0);
  ra.resize(n, 0);
  la.resize(n, 0);
  for (int i = (0); i <= (n - 1); i++) {
    cin >> x[i];
  }
  cin >> l >> q;
  stringstream result;
  for (int i = (0); i <= (n - 1); i++) {
    if (i != n - 1) {
      auto ite = upper_bound(x.begin(), x.end(), x[i] + l);
      ite--;
      int j = ite - x.begin();
      ra[i] = j;
    }
    if (i != 0) {
      auto ite = lower_bound(x.begin(), x.end(), x[i] - l);
      int j = ite - x.begin();
      la[i] = j;
    }
  }
  for (int c = (0); c <= (q - 1); c++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a < b) {
      int now = a;
      int cou = 0;
      while (now < b) {
        now = min(ra[now], b);
        cou++;
      }
      result << cou << endl;
    } else {
      int now = a;
      int cou = 0;
      while (now > b) {
        now = max(la[now], b);
        cou++;
      }
      result << cou << endl;
    }
  }
  cout << result.str();
  return 0;
}
