#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int N;
  cin >> N;
  vector<long long> X(N);
  for (int i = 0; i < N; i++) cin >> X[i];
  long long L;
  cin >> L;
  vector<long long> POS(N);
  vector<long long> NEG(N);
  for (int i = 0; i < N - 1; i++) {
    int left = i + 1;
    int right = N;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (X[mid] - X[i] <= L)
        left = mid;
      else
        right = mid;
    }
    POS[i] = left;
  }
  for (int i = N - 1; i > 0; i--) {
    int right = i - 1;
    int left = -1;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (X[i] - X[mid] <= L)
        right = mid;
      else
        left = mid;
    }
    NEG[i] = right;
  }
  int Q;
  int a, b;
  cin >> Q;
  while (Q--) {
    cin >> a >> b;
    a--;
    b--;
    if (a < b) {
      int ans = 0;
      int curr = a;
      while (curr < b) {
        ans++;
        curr = POS[curr];
      }
      cout << ans << endl;
    } else {
      int ans = 0;
      int curr = a;
      while (curr > b) {
        ans++;
        curr = NEG[curr];
      }
      cout << ans << endl;
    }
  }
}
