#include <bits/stdc++.h>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int size = 1000;
struct Node {
  int pos;
  vector<int> reachableIdx;
  Node() : reachableIdx(size, 1e9) {}
};
int main() {
  int n, l, q;
  cin >> n;
  vector<int> xs(n);
  vector<Node> nodes(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    nodes[i].pos = xs[i];
  }
  cin >> l >> q;
  for (int i = 0; i < n; i++) {
    int p = nodes[i].pos;
    nodes[i].reachableIdx[0] = i;
    for (int j = 1; j < size; j++) {
      int rr = p + l;
      int pr = upper_bound(xs.begin(), xs.end(), rr) - xs.begin() - 1;
      nodes[i].reachableIdx[j] = pr;
      p = nodes[pr].pos;
    }
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    a--;
    b--;
    Node n = nodes[a];
    int len = 0;
    while (1) {
      if (n.reachableIdx.back() >= b) {
        len += lower_bound(n.reachableIdx.begin(), n.reachableIdx.end(), b) -
               n.reachableIdx.begin();
        break;
      } else {
        len += size - 1;
        n = nodes[n.reachableIdx.back()];
      }
    }
    cout << len << endl;
  }
  return 0;
}
