#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>>& G, const T INF = 1e9) {
  using P = pair<T, int>;
  int V = G.size();
  vector<T> dist(V, INF);
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.emplace(0, s);
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (dist[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      int to = G[v][i].first;
      T cost = G[v][i].second;
      if (dist[to] > dist[v] + cost) {
        dist[to] = dist[v] + cost;
        que.emplace(dist[to], to);
      }
    }
  }
  return dist;
}
signed main() {
  int n;
  cin >> n;
  vector<ll> x(n);
  for (int i = 0; i < (n); i++) {
    cin >> x[i];
  }
  ll l;
  cin >> l;
  int q;
  cin >> q;
  int a[q], b[q];
  for (int i = 0; i < (q); i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  if (n > 3000 || q > 3000) return 0;
  vector<vector<pair<int, int>>> G(n);
  for (int i = 0; i < (n); i++) {
    G[i].emplace_back(
        upper_bound((x).begin(), (x).end(), x[i] + l) - x.begin() - 1, 1);
    G[upper_bound((x).begin(), (x).end(), x[i] + l) - x.begin() - 1]
        .emplace_back(i, 1);
    G[i].emplace_back(lower_bound((x).begin(), (x).end(), x[i] - l) - x.begin(),
                      1);
    G[lower_bound((x).begin(), (x).end(), x[i] - l) - x.begin()].emplace_back(
        i, 1);
  }
  for (int i = 0; i < (q); i++) {
    vector<int> dist = Dijkstra(a[i], G);
    cout << dist[b[i]] << endl;
  }
  return 0;
}
