#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, a, b, alt;
  long long l;
  cin >> n;
  long long x[n];
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> l >> q;
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      alt = a;
      a = b;
      b = alt;
    }
    long long dp[n];
    for (int i = 0; i < n; i++) dp[i] = 1e10;
    for (int i = a; i < b; i++) {
      if (i == a) dp[i] = 0;
      for (int j = i; j < b + 1; j++) {
        if (x[j] - x[i] <= l)
          dp[j] = min(dp[j], dp[i] + 1);
        else
          break;
      }
    }
    cout << dp[b] << endl;
  }
  return 0;
}
