#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l;
  cin >> n;
  vector<int> x(n), d[n];
  for (int i = 0; i < n; ++i) cin >> x[i];
  cin >> l;
  {
    int j = 1;
    for (int i = 0; i < n; ++i) {
      while (j < n - 1 && x[j + 1] - x[i] <= l) j++;
      if (i != n - 1) d[i].push_back(j);
    }
  }
  for (int i = 0; i < 20; ++i) {
    for (int j = 0; j < n; ++j) {
      if (d[j].size() == i + 1 && d[d[j][i]].size() == i + 1)
        d[j].push_back(d[d[j][i]][i]);
      else
        break;
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = 0;
    while (a != b) {
      for (int j = d[a].size() - 1; j >= 0; --j)
        if (d[a][j] <= b) {
          ans += 1 << j;
          a = d[a][j];
          break;
        }
    }
    cout << ans << endl;
  }
  return 0;
}
