#include <bits/stdc++.h>
using namespace std;
int nxt[65536 * 2][20 + 5];
int pos[65536 * 2];
int n, l, Q;
struct QUERY {
  int l, r, id;
} q[65536 * 2];
int ans[65536 * 2];
void getlg() {
  memset(nxt, 0, sizeof(nxt));
  int r = 1;
  for (int i = 1; i <= n; i++) {
    while (pos[i] - pos[r] > l) r++;
    nxt[i][0] = r;
  }
  nxt[1][0] = 0;
  for (int i = 1; i <= 20; i++)
    for (int j = 1; j <= n; j++) nxt[j][i] = nxt[nxt[j][i - 1]][i - 1];
}
int main() {
  int Q;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &pos[i]);
  cin >> l;
  cin >> Q;
  for (int i = 1; i <= Q; i++) scanf("%d%d", &q[i].l, &q[i].r), q[i].id = i;
  getlg();
  for (int i = 1; i <= Q; i++) {
    if (q[i].l < q[i].r) continue;
    int x = q[i].l;
    for (int j = 20; j >= 0; j--) {
      if (nxt[x][j] > q[i].r) x = nxt[x][j], ans[q[i].id] += (1 << j);
    }
    if (x > q[i].r) ans[q[i].id]++;
  }
  for (int i = 1; i <= n; i++) pos[i] *= -1;
  reverse(pos + 1, pos + n + 1);
  for (int i = 1; i <= Q; i++) {
    q[i].l = n - q[i].l + 1, q[i].r = n - q[i].r + 1;
    if (q[i].l < q[i].r) continue;
    int x = q[i].l;
    for (int j = 20; j >= 0; j--) {
      if (nxt[x][j] > q[i].r) x = nxt[x][j], ans[q[i].id] += (1 << j);
    }
    if (x > q[i].r) ans[q[i].id]++;
  }
  for (int i = 1; i <= Q; i++) printf("%d\n", ans[i]);
  return 0;
}
