#include <bits/stdc++.h>
using namespace std;
long long N, L, Q;
vector<long long> X;
long long dist[100010];
bool isCalc[100010];
pair<long long, long long> AB[100010];
long long bin_search(vector<long long> v, long long b_ind, long long e_ind,
                     long long val) {
  if (v[e_ind] <= val) {
    return -1;
  } else if (v[b_ind] > val) {
    return b_ind;
  }
  long long lb = b_ind, ub = e_ind;
  while (ub - lb > 1) {
    long long mid = (lb + ub) / 2;
    if (v[mid] > val) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  if (v[ub] > val) {
    return ub;
  }
  return -1;
}
int main() {
  cin >> N;
  for (long long i = 0; i < N; ++i) {
    long long tmp;
    scanf("%lld", &tmp);
    X.push_back(tmp);
  }
  cin >> L >> Q;
  for (long long i = 0; i < Q; ++i) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    AB[i] = make_pair(a, b);
  }
  memset(dist, 0, sizeof(dist));
  memset(isCalc, 0, sizeof(isCalc));
  for (long long hotel_s = 0; hotel_s < N; ++hotel_s) {
    if (isCalc[hotel_s]) {
      continue;
    }
    vector<long long> path;
    long long cur = hotel_s;
    long long pad = 0;
    while (cur >= 0 && cur != N - 1) {
      path.push_back(cur);
      cur = bin_search(X, cur, N - 1, X[cur] + L) - 1;
      if (isCalc[cur]) {
        pad = dist[cur];
        break;
      }
    }
    for (long long i = 0; i < path.size(); ++i) {
      dist[path[i]] = path.size() - i + pad;
      isCalc[path[i]] = true;
    }
  }
  for (long long i = 0; i < Q; ++i) {
    printf("%lld\n", abs(dist[AB[i].first] - dist[AB[i].second]));
  }
  return 0;
}
