#include <bits/stdc++.h>
using namespace std;
long long d[1005][1005];
long long dp[1005];
int main() {
  long long n;
  cin >> n;
  vector<long long> v;
  for (long long i = (0); i < (n); ++i) {
    long long a;
    cin >> a;
    v.push_back(a);
  }
  long long l, q;
  cin >> l >> q;
  vector<pair<long long, long long> > vq;
  for (long long i = (0); i < (q); ++i) {
    long long a, b;
    cin >> a >> b;
    vq.push_back(make_pair(min(a, b), max(a, b)));
  }
  if (n > 1000 || q > 1000) return 0;
  memset((d), (0), sizeof(d));
  for (long long i = (0); i < (v.size()); ++i) {
    for (long long j = (i + 1); j < (v.size()); ++j) {
      if (v[j] - v[i] <= l) {
        d[i][j] = 1;
      }
    }
  }
  for (long long i = (0); i < (1005); ++i) dp[i] = 100000;
  dp[0] = 0;
  for (long long i = (0); i < (v.size()); ++i) {
    for (long long j = (i + 1); j < (v.size()); ++j) {
      if (d[i][j] == 1) {
        dp[j] = min(dp[j], dp[i] + 1);
      }
    }
  }
  for (long long i = (0); i < (vq.size()); ++i) {
    long long a = vq[i].first;
    long long b = vq[i].second;
    cout << dp[b] - dp[a] << endl;
  }
  return 0;
}
