#include <bits/stdc++.h>
using namespace std;
const int S = 1e5;
vector<int> m[S];
int x[S];
int N, L;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L;
  int cur = 0;
  for (int i = 0; i < N; i++) {
    while (x[cur] + L < x[i]) {
      m[cur].push_back(i - 1);
      cur++;
    }
  }
  while (cur < N) {
    m[cur].push_back(N - 1);
    cur++;
  }
  for (int j = 1;; j++) {
    bool updated = false;
    for (int i = 0; i < N; i++) {
      if (m[i].back() != N - 1) {
        m[i].push_back(m[m[i].back()].back());
        updated = true;
      }
    }
    if (!updated) {
      break;
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      swap(a, b);
    }
    int ret = 0;
    while (a < b) {
      int j = 0;
      int k = 1;
      while (j + 1 < m[a].size() && m[a][j + 1] <= b) {
        j++;
        k *= 2;
      }
      ret += k;
      a = m[a][j];
    }
    cout << ret << endl;
  }
  return 0;
}
