#include <bits/stdc++.h>
inline int getInt() {
  int s;
  scanf("%d", &s);
  return s;
}
using namespace std;
int main() {
  const int n = getInt();
  vector<int> x(n);
  for (int i = 0; i < (int)(n); i++) x[i] = getInt();
  const int l = getInt();
  const int m = 20;
  vector<vector<int> > dp(n, vector<int>(m));
  for (int i = 0; i < (int)(n); i++) {
    if (i == n - 1)
      dp[i][0] = n - 1;
    else {
      const int xx = x[i];
      int mn = i + 1;
      int mx = n - 1;
      while (mn <= mx) {
        const int med = (mn + mx) / 2;
        const int d = x[med] - xx;
        if (d <= l)
          mn = med + 1;
        else
          mx = med - 1;
      }
      dp[i][0] = mx;
      if (mx == i) throw 0;
    }
  }
  for (int i = 1; i < m; i++) {
    for (int j = 0; j < (int)(n); j++) {
      const int c = dp[j][i - 1];
      dp[j][i] = dp[c][i - 1];
    }
  }
  const int q = getInt();
  for (int i = 0; i < (int)(q); i++) {
    int a = getInt() - 1;
    int b = getInt() - 1;
    if (a > b) swap(a, b);
    int p = a;
    int ans = 0;
    while (p < b) {
      for (int i = 0; i < m; i++) {
        if (dp[p][i] >= b || (dp[p][i] <= b && dp[p][i + 1] > b)) {
          p = dp[p][i];
          ans += 1 << i;
          break;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
