#include <bits/stdc++.h>
using namespace std;
static const long long INF = 1e15;
long long mod = 1e9 + 7;
template <typename T>
static inline void chmin(T& ref, const T value) {
  if (ref > value) ref = value;
}
template <typename T>
static inline void chmax(T& ref, const T value) {
  if (ref < value) ref = value;
}
class lca {
 public:
  const int n;
  const int log2_n;
  std::vector<std::vector<int>> parent;
  std::vector<int> depth;
  lca(const vector<vector<int>>& g, int root)
      : n(g.size()),
        log2_n(log2(n) + 1),
        parent(log2_n, std::vector<int>(n)),
        depth(n) {
    dfs(g, root, -1, 0);
    for (int k = 0; k + 1 < log2_n; k++) {
      for (int v = 0; v < (int)g.size(); v++) {
        if (parent[k][v] < 0)
          parent[k + 1][v] = -1;
        else
          parent[k + 1][v] = parent[k][parent[k][v]];
      }
    }
  }
  void dfs(const vector<vector<int>>& g, int v, int p, int d) {
    parent[0][v] = p;
    depth[v] = d;
    for (int j = 0; j < g[v].size(); j++) {
      if (g[v][j] != p) dfs(g, g[v][j], v, d + 1);
    }
  }
  int get(int u, int v) {
    if (depth[u] > depth[v]) std::swap(u, v);
    for (int k = 0; k < log2_n; k++) {
      if ((depth[v] - depth[u]) >> k & 1) {
        v = parent[k][v];
      }
    }
    if (u == v) return u;
    for (int k = log2_n - 1; k >= 0; k--) {
      if (parent[k][u] != parent[k][v]) {
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
};
struct UnionFind {
 public:
  vector<long long> par;
  vector<long long> siz;
  UnionFind() {}
  UnionFind(long long sz_) : par(sz_), siz(sz_, 1LL) {
    for (long long i = 0; i < sz_; ++i) par[i] = i;
  }
  void init(long long sz_) {
    par.resize(sz_);
    siz.assign(sz_, 1LL);
    for (long long i = 0; i < sz_; ++i) par[i] = i;
  }
  long long root(long long x) {
    while (par[x] != x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }
  bool merge(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  bool issame(long long x, long long y) { return root(x) == root(y); }
  long long size(long long x) { return siz[root(x)]; }
};
int main() {
  long long n;
  cin >> n;
  vector<long long> xs(n);
  for (long long i = 0; i < n; i++) {
    cin >> xs[i];
  }
  long long L, q;
  cin >> L >> q;
  vector<pair<long long, long long>> qs(q);
  for (long long i = 0; i < q; i++) {
    cin >> qs[i].first >> qs[i].second;
  }
  int j = 0;
  vector<vector<int>> graph(n);
  for (int i = 0; i < n && j < n; i++) {
    long long dist = 0;
    while (true) {
      dist = xs[j] - xs[i];
      if (dist > L) {
        graph[i].push_back(j - 1);
        break;
      }
      j++;
      if (j == n) {
        break;
      }
    }
  }
  vector<bool> visit(n, false);
  vector<int> rootArray(n, -1);
  map<int, vector<int>> rootToArray;
  function<void(int, int)> dfs = [&](int current, int root) {
    if (visit[current]) return;
    visit[current] = true;
    rootArray[current] = root;
    rootToArray[root].push_back(current);
    for (auto p : graph[current]) {
      if (p > current) dfs(p, root);
    }
  };
  for (int i = 0; i < n; i++) {
    dfs(i, i);
  }
  for (long long i = 0; i < q; i++) {
    auto uid = qs[i].first - 1;
    auto vid = qs[i].second - 1;
    auto ur = rootArray[uid];
    auto vr = rootArray[vid];
    auto l = min(ur, vr);
    auto u1 = lower_bound(rootToArray[l].begin(), rootToArray[l].end(), uid);
    auto u2 = upper_bound(rootToArray[l].begin(), rootToArray[l].end(), vid);
    cout << abs(u2 - u1 - 1) << endl;
  }
  return 0;
}
