#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll modpow(ll x, ll y) {
  ll res = 1;
  while (y) {
    if (y % 2) {
      res *= x;
      res %= mod;
    }
    x = x * x % mod;
    y /= 2;
  }
  return res;
}
struct edge {
  ll to, cost;
};
typedef pair<ll, ll> P;
ll d[213456];
vector<edge> G[213456];
void dijkstra(ll s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d + 213456, INF);
  d[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) {
      continue;
    }
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}
ll test[12345678];
signed main() {
  ll n, x, l, q, a, b;
  cin >> n;
  for (int h = 0; h < n; h++) {
    cin >> test[h];
  }
  cin >> l >> q;
  ll mae = -1, ato = 0;
  while (true) {
    if (mae == n - 1) {
      break;
    }
    mae++;
    while (true) {
      if (ato != n - 1 && test[ato + 1] - test[mae] <= l) {
        ato++;
      } else {
        break;
      }
    }
    G[mae + 1].push_back({ato + 1, 1});
  }
  for (int h = 0; h < q; h++) {
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    dijkstra(a);
    cout << d[b] << endl;
  }
  return 0;
}
