#include <bits/stdc++.h>
using namespace std;
using Int = long long;
vector<pair<int, int> > G[100005];
class LCA {
 public:
  int V, logV;
  vector<int> depth, len;
  vector<vector<int> > parent;
  LCA(int V) {
    this->V = V;
    logV = 0;
    while (V > (1LL << logV)) logV++;
    this->depth = vector<int>(V);
    this->len = vector<int>(V);
    this->parent = vector<vector<int> >(logV, vector<int>(V));
  }
  void init(int v, int par, int d, int l) {
    depth[v] = d;
    parent[0][v] = par;
    len[v] = l;
    for (int i = 0; i < (int)G[v].size(); i++) {
      int w = G[v][i].first;
      int lc = G[v][i].second;
      if (w == par) continue;
      init(w, v, d + 1, lc + l);
    }
  }
  void build() {
    for (int k = 0; k + 1 < logV; k++) {
      for (int v = 0; v < V; v++) {
        if (parent[k][v] < 0)
          parent[k + 1][v] = -1;
        else
          parent[k + 1][v] = parent[k][parent[k][v]];
      }
    }
  }
  int query(int u, int v) {
    if (depth[u] > depth[v]) swap(u, v);
    for (int k = 0; k < logV; k++) {
      if ((depth[v] - depth[u]) >> k & 1) v = parent[k][v];
    }
    if (u == v) return u;
    for (int k = logV - 1; k >= 0; k--) {
      if (parent[k][u] != parent[k][v]) {
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
};
int main(void) {
  Int n;
  cin >> n;
  vector<Int> x(n);
  for (Int i = 0; i < n; i++) {
    cin >> x[i];
  }
  Int L, q;
  cin >> L >> q;
  for (Int i = 0; i < n - 1; i++) {
    Int idx = lower_bound(x.begin(), x.end(), x[i] + L + 1) - x.begin() - 1;
    G[i].push_back({idx, 1});
    G[idx].push_back({i, 1});
  }
  LCA lca(n);
  lca.init(0, -1, 0, 0);
  lca.build();
  for (Int i = 0; i < q; i++) {
    Int a, b;
    cin >> a >> b;
    a--;
    b--;
    Int c = lca.query(a, b);
    cout << lca.len[a] + lca.len[b] - 2 * lca.len[c] << endl;
  }
}
