#include <bits/stdc++.h>
using namespace std;
const int INF = numeric_limits<int>::max();
const long long LLINF = numeric_limits<long long>::max();
const unsigned long long ULLINF = numeric_limits<unsigned long long>::max();
const double PI = acos(-1.0);
long long x[100010], l;
int n;
int r[18][100010];
int binsearch(int i) {
  int tl = i, tr = n, res = i + 1;
  while (tl <= tr) {
    int tm = (tl + tr) >> 1;
    if (x[i] + l >= x[tm])
      res = tm, tl = tm + 1;
    else
      tr = tm - 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> l;
  for (int i = 0; i < n; i++) r[0][i] = upper_bound(x, x + n, x[i] + l) - 1 - x;
  for (int h = 1; h < 16; h++) {
    for (int i = 0; i < n; i++) {
      r[h][i] = r[h - 1][r[h - 1][i]];
      if (r[h][i] == 0) r[h][i] = n;
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int tl = 1, tr = n, res = n;
    while (tl <= tr) {
      int tm = (tl + tr) >> 1;
      int cur = tm;
      int c = a, p = 0;
      while (cur) {
        if (cur % 2) c = r[p][c];
        cur >>= 1;
        p++;
      }
      if (c == 0 || c >= b)
        res = tm, tr = tm - 1;
      else
        tl = tm + 1;
    }
    cout << res << '\n';
  }
  return 0;
}
