#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  set<int> s;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    s.insert(x[i]);
  }
  int l, q;
  cin >> l >> q;
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    if (b < a) swap(a, b);
    auto start = x[a - 1];
    auto goal = x[b - 1];
    int days = 1;
    for (;;) {
      auto hotel = s.lower_bound(start + l);
      if (start + l < *hotel) {
        --hotel;
      }
      if (goal <= *hotel) {
        break;
      } else {
        start = *hotel;
        days++;
      }
    }
    cout << days << "\n";
  }
}
