#include <bits/stdc++.h>
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
const int MAXN = 100100;
int N, L, Q;
int X[MAXN];
int nxt[30][MAXN], prv[30][MAXN];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; i++) cin >> X[i];
  cin >> L;
  memset(nxt, -1, sizeof(nxt));
  memset(prv, -1, sizeof(prv));
  for (int i = 0; i < N; i++) {
    if (i == N - 1) {
      nxt[0][i] = N - 1;
      continue;
    }
    int low = i + 1, high = N;
    while (high - low > 1) {
      int med = (high + low) / 2;
      if (X[med] - X[i] <= L)
        low = med;
      else
        high = med;
    }
    nxt[0][i] = low;
  }
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      prv[0][i] = 0;
      continue;
    }
    int low = -1, high = i;
    while (high - low > 1) {
      int med = (high + low) / 2;
      if (X[i] - X[med] <= L)
        high = med;
      else
        low = med;
    }
    prv[0][i] = high;
  }
  for (int i = 0; i < 30 - 1; i++) {
    for (int j = 0; j < N; j++) {
      if (nxt[i][j] == -1)
        nxt[i + 1][j] = -1;
      else
        nxt[i + 1][j] = nxt[i][nxt[i][j]];
      assert(nxt[i][j] != -1);
      if (prv[i][j] == -1)
        prv[i + 1][j] = -1;
      else
        prv[i + 1][j] = prv[i][prv[i][j]];
      assert(prv[i][j] != -1);
    }
  }
  cin >> Q;
  for (int t = 0; t < Q; t++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a < b) {
      int ans = 0;
      for (int i = 30 - 1; i >= 0; i--) {
        if (nxt[i][a] < b) ans |= 1 << i;
      }
      cout << ans + 1 << endl;
    } else {
      int ans = 0;
      for (int i = 30 - 1; i >= 0; i--) {
        if (prv[i][a] > b) ans |= 1 << i;
      }
      cout << ans + 1 << endl;
    }
  }
  return 0;
}
