#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
struct Doubling {
  int sz, n;
  vector<vector<int>> table;
  Doubling(int n, long long ma = 1LL << 62) : sz(0), n(n) {
    while ((1LL << sz) < ma) ++sz;
    table.assign(sz, vector<int>(n, -1));
  }
  void set_next(int i, int x) { table[0][i] = x; }
  void build() {
    for (int k = 0; k < sz - 1; k++)
      for (int i = 0; i < n; i++) {
        if (~table[k][i]) table[k + 1][i] = table[k][table[k][i]];
      }
  }
  int query(int i, long long t) {
    for (int k = sz - 1; k >= 0; k--) {
      if (t >> k & 1) i = table[k][i];
    }
    return i;
  }
  long long lower_bound(long long s, long long t) {
    long long ret = 0LL;
    for (int k = sz - 1; k >= 0; k--) {
      if (table[k][s] <= t) {
        ret |= 1LL << k;
        s = table[k][s];
      }
    }
    return ret;
  }
};
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int &xi : x) cin >> xi;
  x.emplace_back(INF);
  int l;
  cin >> l;
  Doubling dbl(n);
  int nxt = 0;
  for (int i = 0; i < n; i++) {
    while (x[nxt] - x[i] <= l) nxt++;
    dbl.set_next(i, nxt - 1);
  }
  dbl.build();
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    cout << dbl.lower_bound(a, b) << endl;
  }
  return 0;
}
