#include <bits/stdc++.h>
using namespace std;
int a[100001], block[100001], block_no, start[100001], finish[100001],
    sz = 400, cnt[100001], nxt[100001];
int main() {
  ios::sync_with_stdio(false);
  ;
  cin.tie(0);
  ;
  int i, j, n, q, x, y, l, r, L, curl, ind, ctr = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  cin >> L;
  for (i = 1; i <= n; i++) {
    block_no++;
    start[block_no] = i;
    for (j = i; j <= min(n, i + sz - 1); j++) block[j] = i;
    finish[block_no] = min(n, i + sz - 1);
    i = i + sz - 1;
  }
  for (i = n; i >= 1; i--) {
    x = a[i] + L;
    if (a[n] <= a[i] + L)
      ind = n;
    else {
      ind = lower_bound(a + 1, a + n + 1, x) - a;
      if (a[ind] > a[i] + L) ind--;
    }
    if (block[ind] != block[i]) {
      cnt[i] = 1;
      nxt[i] = ind;
    } else {
      cnt[i] = cnt[ind] + 1;
      nxt[i] = nxt[ind];
    }
  }
  cin >> q;
  while (q--) {
    cin >> l >> r;
    if (l > r) swap(l, r);
    ctr = 0;
    curl = l;
    if (block[l] != block[r]) {
      curl = l;
      ctr = cnt[curl];
      curl = nxt[curl];
    }
    while (1) {
      if (block[curl] == block[r]) break;
      ctr += cnt[curl];
      curl = nxt[curl];
    }
    while (1) {
      if (curl >= r) {
        cout << ctr << "\n";
        break;
      }
      x = a[curl] + L;
      if (a[n] <= a[curl] + L)
        curl = n;
      else {
        ind = lower_bound(a + 1, a + n + 1, x) - a;
        if (a[ind] > a[curl] + L) ind--;
        curl = ind;
      }
      ctr++;
    }
  }
  return 0;
}
