#include <bits/stdc++.h>
using namespace std;
long long nextInt() {
  long long a;
  cin >> a;
  return a;
}
char nextChar() {
  char a;
  cin >> a;
  return a;
}
double nextDouble() {
  double a;
  cin >> a;
  return a;
}
string nextString() {
  string a;
  cin >> a;
  return a;
}
void inputVector(vector<long long> &v, long long &n) {
  for (long long i = 0; i < (n); i++) {
    v.push_back(nextInt());
  }
}
void inputVector(vector<double> &v, long long &n) {
  for (long long i = 0; i < (n); i++) {
    v.push_back(nextDouble());
  }
}
void inputVector(vector<string> &v, long long &n) {
  for (long long i = 0; i < (n); i++) {
    v.push_back(nextString());
  }
}
signed main() {
  long long N;
  cin >> N;
  vector<long long> x;
  inputVector(x, N);
  vector<long long> nx(N);
  long long L, Q;
  cin >> L >> Q;
  if (N > 1000 || Q > 1000) {
    cout << 0 << endl;
    return 0;
  }
  for (long long i = 0; i < N; i++) {
    long long pt = i;
    while (pt < N && x[pt] - x[i] <= L) {
      pt++;
    }
    nx[i] = pt - 1;
  }
  for (long long loop = 0; loop < (Q); loop++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      swap(a, b);
    }
    long long ret = 0;
    while (a < b) {
      a = nx[a];
      ret++;
    }
    cout << ret << endl;
  }
  return 0;
}
