#include <bits/stdc++.h>
using namespace std;
int x[100001] = {};
int d[100001] = {};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> x[i];
  }
  int L;
  cin >> L;
  priority_queue<pair<int, int>> pq;
  pq.push({0, 1});
  fill(d + 1, d + N + 1, -1);
  d[1] = 0;
  while (!pq.empty()) {
    auto top = pq.top();
    pq.pop();
    for (int j = top.second + 1; j <= N && x[j] - x[top.second] <= L; j++) {
      if (d[j] == -1) {
        d[j] = -top.first + 1;
        pq.push({-d[j], j});
      } else {
        break;
      }
    }
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int a, b;
    cin >> a >> b;
    if (a != b && d[b] == d[a]) {
      cout << 1 << endl;
    } else {
      cout << abs(d[b] - d[a]) << endl;
    }
  }
  return 0;
}
