#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int nxt[111111][22];
int pre[111111][22];
int n, q;
long long L;
int main() {
  cin >> n;
  for (long long(i) = (0); (i) < (n); ++i) {
    int tmp;
    cin >> tmp;
    v.emplace_back(tmp);
  }
  cin >> L;
  for (long long(i) = (0); (i) < (n); ++i) {
    if (i == n - 1)
      nxt[i][0] = n;
    else {
      nxt[i][0] = (upper_bound(v.begin(), v.end(), v[i] + L) - v.begin()) - 1;
    }
    if (i == 0)
      pre[i][0] = -1;
    else {
      pre[i][0] = (lower_bound(v.begin(), v.end(), v[i] - L) - v.begin());
    }
  }
  for (long long(i) = (0); (i) < (21); ++i) {
    for (long long(j) = (0); (j) < (n); ++j) {
      if (nxt[j][i] == n)
        nxt[j][i + 1] = n;
      else
        nxt[j][i + 1] = nxt[nxt[j][i]][i];
      if (pre[j][i] == -1)
        pre[j][i + 1] = -1;
      else
        pre[j][i + 1] = pre[pre[j][i]][i];
    }
  }
  cin >> q;
  for (long long(seica) = (0); (seica) < (q); ++seica) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    long long ans = 0;
    long long now = a;
    if (a < b) {
      for (int i = 21; i >= 0; i--) {
        if (i == 0 || nxt[now][i] <= b) {
          ans += (1 << i);
          now = nxt[now][i];
        }
        if (now == b) break;
      }
      if (now != b) ans++;
    } else {
      for (int i = 21; i >= 0; i--) {
        if (i == 0 || pre[now][i] >= b) {
          ans += (1 << i);
          now = pre[now][i];
        }
        if (now == b) break;
      }
      if (now != b) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
