#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int64_t> x(n);
  for (auto &i : x) cin >> i;
  int64_t L;
  cin >> L;
  int l[1 << 17][17], r[1 << 17][17];
  int lch, rch;
  rch = 0;
  for (lch = 0; lch < n; ++lch) {
    while (rch != n && x[rch] - x[lch] <= L) rch++;
    l[lch][0] = rch - 1;
  }
  for (rch = n - 1; rch >= 0; --rch) {
    while (lch != -1 && x[rch] - x[lch] <= L) lch--;
    r[rch][0] = lch + 1;
  }
  for (int p = 1; p < 17; ++p) {
    for (int i = 0; i < n; ++i) {
      l[i][p] = l[l[i][p - 1]][p - 1];
      r[i][p] = r[r[i][p - 1]][p - 1];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a < b) {
      int ans = 0;
      while (a < b) {
        for (int i = 16; i >= 0; --i) {
          if (l[a][i] < b || i == 0) {
            ans += (1 << i);
            a = l[a][i];
            break;
          }
        }
      }
      cout << ans << endl;
    } else {
      int ans = 0;
      while (a > b) {
        for (int i = 16; i >= 0; --i) {
          if (r[a][i] > b || i == 0) {
            ans += 1 << i;
            a = r[a][i];
            break;
          }
        }
      }
      cout << ans << endl;
    }
  }
}
