#include <bits/stdc++.h>
const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const long long linf = (long long)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
using namespace std;
int n, L;
int a[N], up[20][N];
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = (1); i <= (n); i++) cin >> a[i];
  cin >> L;
  int ptr = n;
  for (int i = (n); i >= (1); i--) {
    while (a[ptr] - a[i] > L) ptr--;
    up[0][i] = ptr;
  }
  for (int dg = (1); dg <= (19); dg++) {
    for (int i = (1); i <= (n); i++) {
      up[dg][i] = up[dg - 1][up[dg - 1][i]];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    int ans = 0;
    if (l < r) {
      while (l < r) {
        int j = l;
        while (j + 1 <= r && a[j + 1] - a[l] <= L) j++;
        l = j;
        ++ans;
      }
      cout << ans << '\n';
    } else {
      while (l > r) {
        int j = l;
        while (j - 1 >= r && a[l] - a[j - 1] <= L) j--;
        l = j;
        ++ans;
      }
      cout << ans << '\n';
    }
  }
  exit(0);
}
