#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
  return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
  for (int i = 0; i < P.size(); ++i) {
    if (i > 0) {
      s << " ";
    }
    s << P[i];
  }
  return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
  for (int i = 0; i < P.size(); ++i) {
    s << endl << P[i];
  }
  return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
  for (__typeof__((P).begin()) it = (P).begin(); it != (P).end(); ++it) {
    s << "<" << it->first << "->" << it->second << "> ";
  }
  return s << endl;
}
const int MAX = 210000;
int N;
int x[MAX];
int L;
int Q;
int ne[30][MAX];
void PreProcess() {
  for (int i = 0; i < N; ++i) {
    int hi = N, lo = i;
    while (hi - lo > 1) {
      int mid = (hi + lo) / 2;
      if (x[mid] - x[i] > L)
        hi = mid;
      else
        lo = mid;
    }
    ne[0][i] = lo;
  }
  for (int i = 0; i < 30; ++i) {
    for (int j = 0; j < N; ++j) {
      ne[i + 1][j] = ne[i][ne[i][j]];
    }
  }
}
int Query(int a, int b) {
  if (a > b) swap(a, b);
  int res = 0;
  for (int bit = 24; bit >= 0; --bit) {
    if (ne[bit][a] < b) {
      res += 1 << bit;
      a = ne[bit][a];
    } else if (ne[bit][a] == b && bit == 1) {
      res += 1 << bit;
      a = ne[bit][a];
    }
    if (a >= b) break;
  }
  if (a < b) res += 1;
  return res;
}
int main() {
  while (cin >> N) {
    for (int i = 0; i < N; ++i) {
      scanf("%d", &x[i]);
    }
    x[N] = x[N - 1] + 1;
    cin >> L;
    PreProcess();
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
      int a, b;
      scanf("%d %d", &a, &b);
      --a, --b;
      cout << Query(a, b) << endl;
    }
  }
}
