#include <bits/stdc++.h>
using namespace std;
int nxt[20][100010];
int inp[100010];
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> inp[i];
  }
  int l;
  cin >> l;
  for (int j = 0; j < 20; j++) {
    for (int i = 0; i < 100010; i++) {
      nxt[j][i] = 100005;
    }
    nxt[j][100005] = 100005;
  }
  int lst = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    while (inp[lst] - inp[i] > l) {
      lst--;
    }
    nxt[0][i] = lst;
  }
  for (int j = 1; j < 20; j++) {
    for (int i = 0; i < n; i++) {
      nxt[j][i] = nxt[j - 1][nxt[j - 1][i]];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    if (a > b) swap(a, b);
    int ans = 0;
    for (int j = 19; j >= 0; j--) {
      if (nxt[j][a] < b) {
        a = nxt[j][a];
        ans += (1 << j);
      } else if (nxt[j][a] == b) {
        ans += (1 << j);
        break;
      }
    }
    cout << ans << endl;
  }
}
