#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);
  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;
  }
  int Q;
  int a, b;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      int temp = b;
      b = a;
      a = temp;
    }
    int ans = 0;
    int curr = a;
    while (curr < b) {
      ans++;
      curr = POS[curr];
    }
    cout << ans << endl;
  }
}
