#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  long long N, L, Q;
  long long a[114514], b[114514];
  vector<long long> x;
  cin >> N;
  long long y;
  for (long long i = 0; i < (N); ++i) {
    cin >> y;
    y--;
    x.push_back(y);
  }
  cin >> L >> Q;
  for (long long i = 0; i < (Q); ++i) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (b[i] < a[i]) swap(a[i], b[i]);
  }
  long long dp[20][114514];
  for (long long i = 0; i < (N); ++i) {
    dp[0][i] =
        -1 + (long long)(upper_bound(x.begin(), x.end(), x[i] + L) - x.begin());
  }
  for (long long k = 0; (1 << k) < N; k++) {
    for (long long i = 0; i < (N); ++i) {
      dp[k + 1][i] = dp[k][dp[k][i]];
    }
  }
  for (long long j = 0; j < (Q); ++j) {
    long long P = a[j], R = b[j];
    long long l = 0, r = N, mid;
    while (abs(r - l) > 1) {
      mid = (l + r) / 2;
      long long now = P;
      long long m = mid, k = 0;
      while (m > 0) {
        if (m % 2 == 1) {
          now = dp[k][now];
        }
        k++;
        m /= 2;
      }
      if (now > R) {
        r = mid;
      } else {
        l = mid;
      }
    }
    cout << l << endl;
  }
  return 0;
}
