#include <bits/stdc++.h>
#pragma warning(disable : 4996)
const long long INF = (1ll << 63) - 1ll;
const long double INFd = 28e14;
const long long inf = (1 << 31) - 1;
const long double EPS = 1e-8;
const long double PI = acos(-1.0);
using namespace std;
void OUT(bool f) {
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void Out(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void out(bool f) {
  if (f)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}
inline int next_rand() { return abs(rand() * rand() + rand()); }
struct __debug__ {
  __debug__(string filename, bool f = false) {
    if (filename == "") return;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string filein = filename + ".in";
    string fileout = filename + ".out";
    freopen(filein.c_str(), "r", stdin);
    freopen(fileout.c_str(), "w", stdout);
  }
  ~__debug__() {}
};
__debug__ DEBUG("");
void gen();
void solve();
int main() {
  srand('M' + 'A' + 'S' + 'L' + '0' + 'F');
  srand(time(0));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
int a[100500];
int dp[17][100500];
void solve() {
  memset(dp, -1, sizeof(dp));
  int n, l, q;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  cin >> l;
  int u = 0;
  for (int i = 0; i < n; ++i) {
    while (u < n && a[u] - a[i] <= l) ++u;
    dp[0][i] = u - 1;
  }
  dp[0][n - 1] = n;
  for (int i = 1; i <= 16; ++i) {
    for (int u = 0; u + (1 << i) < n; ++u) {
      dp[i][u] = dp[i - 1][dp[i - 1][u]];
    }
  }
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    if (l > r) swap(l, r);
    int ans = 0;
    for (int i = 16; i >= 0; --i) {
      if (dp[i][l] != -1 && dp[i][l] <= r) {
        ans += (1 << i);
        l = dp[i][l];
      }
    }
    cout << ans << endl;
  }
}
