#include <bits/stdc++.h>
using namespace std;
long long d[1005][1005];
struct edge {
  int to, cost;
};
vector<edge> G[1005];
int mn[1005];
void ae(int from, int to, int cost) {
  edge e = {to, cost};
  G[from].push_back(e);
}
void dijk(int start, int V) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      que;
  for (int i = 0; i < V; i++) mn[i] = 1000000000;
  mn[start] = 0;
  que.push(pair<int, int>(0, start));
  while (!que.empty()) {
    pair<int, int> p = que.top();
    que.pop();
    int v = p.second;
    if (mn[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (mn[e.to] > mn[v] + e.cost) {
        mn[e.to] = mn[v] + e.cost;
        que.push(pair<int, int>(mn[e.to], e.to));
      }
    }
  }
}
int main() {
  long long n;
  cin >> n;
  vector<long long> v;
  for (long long i = (0); i < (n); ++i) {
    long long a;
    cin >> a;
    v.push_back(a);
  }
  long long l, q;
  cin >> l >> q;
  vector<pair<long long, long long> > vq;
  for (long long i = (0); i < (q); ++i) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    vq.push_back(make_pair(min(a, b), max(a, b)));
  }
  if (n > 1000 || q > 1000) return 0;
  memset((d), (0), sizeof(d));
  for (long long i = (0); i < (v.size()); ++i) {
    for (long long j = (i + 1); j < (v.size()); ++j) {
      if (v[j] - v[i] <= l) {
        ae(i, j, 1);
      }
    }
  }
  for (long long i = (0); i < (q); ++i) {
    long long a = vq[i].first;
    long long b = vq[i].second;
    dijk(a, v.size());
    cout << mn[b] << endl;
  }
  return 0;
}
