#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (auto& i : x) cin >> i;
  int L, Q;
  cin >> L >> Q;
  while (Q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    vector<int> dp(N, INF);
    dp[a] = 0;
    for (int i = a; i < b; i++) {
      for (int j = i + 1; x[j] - x[i] <= L && j < b; j++) {
        dp[j] = min(dp[j], dp[i] + 1);
      }
    }
    cout << dp[b] << endl;
  }
  return 0;
}
