#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l, q;
  cin >> n;
  vector<pair<int, int>> arr;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    x[i] = t;
    arr.push_back({t, i});
  }
  sort(arr.begin(), arr.end());
  sort(x.begin(), x.end());
  cin >> l >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    int ai, bi;
    a--;
    b--;
    for (int i = 0; i < n; i++) {
      if (arr[i].second == a) ai = arr[i].first;
      if (arr[i].second == b) bi = arr[i].first;
    }
    if (ai > bi) swap(ai, bi);
    int d = 0;
    while (ai < bi) {
      int t = upper_bound(x.begin(), x.end(), ai + l) - x.begin();
      ai = x[t - 1];
      d++;
    }
    cout << d << endl;
  }
}
