#include <bits/stdc++.h>
using namespace std;
unsigned long long n, a[100000], i, l, q, c, d, j, x[100000], y[100000], k;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    x[i] = n - 1;
    y[i] = 0;
  }
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> l >> q;
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (a[j] - a[i] > l) {
        x[i] = j - 1;
        break;
      }
    }
    for (j = i - 1; j >= 0; j--) {
      if (a[i] - a[j] > l) {
        y[i] = j + 1;
        break;
      }
    }
  }
  for (i = 0; i < q; i++) {
    cin >> c >> d;
    if (c == d) {
      cout << 0 << endl;
    }
    if (c < d) {
      for (j = c, k = 0;; j = x[j], k++) {
        if (j >= d) {
          cout << k << endl;
          break;
        }
      }
    }
    if (c > d) {
      for (j = c, k = 0;; j = y[j], k++) {
        if (j <= d) {
          cout << k << endl;
          break;
        }
      }
    }
  }
}
