#include <bits/stdc++.h>
using namespace std;
const int N = 100100, M = 20;
int go[N][M];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, l;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  cin >> l;
  for (int i = 0; i < n; ++i) {
    go[i][0] = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
  }
  for (int j = 1; j < M; ++j) {
    for (int i = 0; i < n; ++i) {
      go[i][j] = go[go[i][j - 1]][j - 1];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a > b) {
      swap(a, b);
    }
    int ans = 0;
    for (int i = M - 1; i >= 0; --i) {
      if (go[a][i] >= b) {
        continue;
      } else {
        ans += 1 << i;
      }
    }
    cout << ans + 1 << '\n';
  }
  return 0;
}
