#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int dp[maxn][21], a[maxn], n, L;
int ask(int x, int c) {
  int pos = x;
  if (pos == -1) return 1e9;
  for (int i = 20; i >= 0; i--) {
    if (c & (1 << i)) {
      pos = dp[pos][i];
      if (pos == -1) return 1e9;
    }
  }
  if (pos == -1) return 1e9;
  return pos;
}
void solve() {
  for (int i = 1; i <= n; i++) {
    int l = 1, r = n, mid;
    while (l <= r) {
      mid = l + r >> 1;
      if (a[mid] <= a[i] + L)
        l = mid + 1;
      else
        r = mid - 1;
    }
    dp[i][0] = r;
  }
  dp[n][0] = -1;
  for (int i = 1; i <= 20; i++) {
    for (int j = 1; j <= n; j++) {
      if (dp[j][i - 1] == -1)
        dp[j][i] = -1;
      else
        dp[j][i] = dp[dp[j][i - 1]][i - 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 20; j++)
      if (dp[i][j - 1] == 9 || dp[i][j - 1] == -1) dp[i][j] = -1;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> L;
  solve();
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    int l = 1, r = n;
    while (l <= r) {
      int mid = l + r >> 1;
      if (ask(x, mid) > y)
        r = mid - 1;
      else
        l = mid + 1;
    }
    if (ask(x, r) < y) r++;
    cout << r << endl;
  }
  return 0;
}
