#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-9;
template <class T>
bool INRANGE(T x, T a, T b) {
  return a <= x && x <= b;
}
template <class T>
void amin(T &a, T v) {
  if (a > v) a = v;
}
template <class T>
void amax(T &a, T v) {
  if (a < v) a = v;
}
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) {
  return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y)));
}
double SQSUM(double x, double y) { return x * x + y * y; }
int main() {
  int N;
  cin >> N;
  vector<long long> x(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  long long L;
  int Q;
  cin >> L >> Q;
  vector<int> a(Q), b(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    int now = a[i];
    int turn = 0;
    while (now != b[i]) {
      turn++;
      int next = now;
      if (now > b[i]) {
        while (next > b[i]) {
          if (abs(x[next - 1] - x[now]) <= L) {
            next--;
          } else {
            break;
          }
        }
      } else if (now < b[i]) {
        while (next < b[i]) {
          if (abs(x[next + 1] - x[now]) <= L) {
            next++;
          } else {
            break;
          }
        }
      }
      now = next;
    }
    cout << turn << endl;
  }
}
