#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;
  vector<vector<int>> hotel_dist(n);
  for (int i = 0; i < n; ++i) {
    int days = 1;
    int start = x[i];
    for (;;) {
      auto hotel = s.lower_bound(start + l);
      if (hotel == s.end()) break;
      if (start + l < *hotel) --hotel;
      start = *hotel;
      if ((days & (days - 1)) == 0) {
        hotel_dist[i].push_back(start);
      }
      ++days;
    }
  }
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    if (b < a) swap(a, b);
    auto dists = hotel_dist[a - 1];
    auto goal = x[b - 1];
    auto start_idx = lower_bound(dists.begin(), dists.end(), goal);
    int start, days;
    if (start_idx == dists.end()) {
      start = x[a - 1];
      days = 1;
    } else {
      start = *start_idx;
      days = pow(2, distance(dists.begin(), start_idx));
    }
    while (start < goal) {
      auto hotel = s.lower_bound(start + l);
      if (hotel == s.end()) break;
      if (start + l < *hotel) {
        --hotel;
      }
      start = *hotel;
      days++;
    }
    cout << days << "\n";
  }
}
