#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, size_t N, class T>
void Fill(A (&a)[N], const T &v) {
  fill((T *)a, (T *)(a + N), v);
}
const int INF = 0x3fffffff;
int m[100005][20] = {};
int main() {
  int N, L;
  int x[100005];
  cin >> N;
  for (int i = 0; i < (N); i++) cin >> x[i];
  cin >> L;
  int l = 0;
  for (int i = 0; i < (N); i++) {
    while (x[i] - x[l] > L) l++;
    for (int p = l, j = 0; p > 0; p = m[p][j], j++) {
      m[i][j] = p;
    }
  }
  int Q, a[100005], b[100005];
  cin >> Q;
  for (int i = 0; i < (Q); i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  for (int i = 0; i < (Q); i++) {
    int ans = 0;
    for (int p = b[i], k = 0; p > a[i]; p = m[p][k], k = 0) {
      for (int j = 0; m[p][j] > a[i]; j++) k++;
      if (k == 0)
        ans++;
      else
        ans += (1 << (k - 1));
    }
    cout << ans << endl;
  }
  return 0;
}
