#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, L, Q, a, b, cur, c, ans;
  vector<int> x;
  cin >> N;
  x.push_back(0);
  for (int i = 0; i < N; i++) {
    cin >> c;
    x.push_back(c);
  }
  cin >> L;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    ans = 1;
    cin >> a >> b;
    if (a > b) swap(a, b);
    cur = x[a];
    while (1) {
      cur = *(upper_bound(x.begin(), x.end(), cur + L) - 1);
      if (cur >= x[b])
        break;
      else
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
