#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x[n];
  for (int i = 0; i < n; i++) cin >> x[i];
  int l;
  cin >> l;
  int q;
  cin >> q;
  int d1[n + 1], d2[n + 1];
  for (int i = 0; i < n; i++) {
    int now = x[i];
    d1[i] = n;
    for (int j = i + 1; j < n; j++) {
      if (x[j] <= now + l)
        d1[i] = j;
      else
        break;
    }
  }
  d1[n] = n;
  int h = pow(n, 0.5);
  for (int i = 0; i < n; i++) {
    d2[i] = n;
    int num = i;
    for (int j = 0; j < h; j++) {
      num = d1[num];
    }
    d2[i] = num;
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = 0;
    int c = 0;
    for (int j = a;;) {
      int num = d2[j];
      if (num > b) {
        int now = j;
        for (int k = j;; k++) {
          ans++;
          now = d1[now];
          if (now == b) {
            cout << ans << endl;
            c = 1;
            break;
          }
        }
      }
      ans += h;
      if (num == b) {
        cout << ans << endl;
        c = 1;
      }
      if (c == 1) break;
      j = num;
    }
  }
}
