#include <bits/stdc++.h>
using namespace std;
long long int n, x[110000], l, numq, a, b, nexth[110000], table[30][110000];
void build_sparse() {
  for (int i = 0; i < 20; i++) {
    if ((1 << i) >= n) break;
    for (int j = 0; j < n; j++) {
      if (i == 0) {
        table[i][j] = nexth[j];
      } else if (table[i - 1][j] == -1) {
        table[i][j] = -1;
      } else {
        if (table[i - 1][table[i - 1][j]] == -1)
          table[i][j] = -1;
        else
          table[i][j] = table[i - 1][table[i - 1][j]];
      }
    }
  }
}
int solve(int x1, int y1) {
  if (x1 >= y1) return 0;
  int j;
  for (j = 0; j < 20; j++) {
    if (table[j][x1] > y1 || table[j][x1] == -1) break;
  }
  j--;
  if (j == -1) return 1;
  return (solve(table[j][x1], y1) + (1 << j));
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> l;
  queue<int> q;
  q.push(0);
  for (int i = 1; i < n; i++) {
    int temp = x[q.front()];
    while (x[i] - temp > l) {
      nexth[q.front()] = i - 1;
      q.pop();
      temp = x[q.front()];
    }
    q.push(i);
  }
  while (!q.empty()) {
    nexth[q.front()] = n - 1;
    q.pop();
  }
  nexth[n - 1] = -1;
  memset(table, -1, sizeof(table));
  build_sparse();
  cin >> numq;
  for (int i = 0; i < numq; i++) {
    cin >> a >> b;
    if (a > b) {
      int temp = a;
      a = b;
      b = temp;
    }
    a--;
    b--;
    int ans = solve(a, b);
    cout << ans << endl;
  }
}
