#include <bits/stdc++.h>
using namespace std;
const char dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int ar[100000];
int main() {
  int n, l, q;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < (n); i++) cin >> x[i];
  cin >> l >> q;
  for (int i = 0; i < (n); i++) {
    for (int j = i; j <= n - 1; j++) {
      if (x[j] - x[i] > l)
        break;
      else
        ar[i] = j;
    }
  }
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (a-- > b--) swap(a, b);
    int cnt = 0;
    while (a < b) {
      cnt++;
      a = ar[a];
    }
    cout << cnt << endl;
  }
  return 0;
}
