#include <bits/stdc++.h>
using namespace std;
mt19937 rnd;
const int N = 1e5 + 10;
const int L = 20;
int x[N], ptr[N][L];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  int len;
  cin >> len;
  for (int j = 0; j <= L - 1; j++) {
    ptr[n + 1][j] = n + 1;
  }
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j <= L - 1; j++) {
      if (i == n) {
        ptr[i][j] = n + 1;
      } else if (j == 0) {
        int lef = i + 1, rig = n;
        while (lef < rig) {
          int mid = (lef + rig) / 2;
          if (x[mid + 1] - x[i] <= len) {
            lef = mid + 1;
          } else {
            rig = mid;
          }
        }
        ptr[i][j] = lef;
      } else {
        ptr[i][j] = ptr[ptr[i][j - 1]][j - 1];
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    int ans = 0;
    for (int j = L - 1; j >= 0; j--) {
      if (ptr[a][j] <= b) {
        a = ptr[a][j];
        ans += (1 << j);
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
