#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long x[n];
  for (int i = 0; i < (int)(n); i++) cin >> x[i];
  long long L;
  cin >> L;
  long long Q;
  cin >> Q;
  long long a[Q], b[Q];
  for (int i = 0; i < (int)(Q); i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  long long logn = ceil(log2((double)n));
  long long dou_hotel[n][logn];
  for (int k = 0; k < (int)(logn); k++) {
    for (int i = 0; i < (int)(n); i++) {
      dou_hotel[i][k] = INT_MAX;
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    if (i == 0)
      dou_hotel[i][0] = 0;
    else
      dou_hotel[i][0] = dou_hotel[i - 1][0];
    int t = dou_hotel[i][0];
    while (t + 1 <= n - 1) {
      if (x[t + 1] - x[i] > L) break;
      t++;
    }
    dou_hotel[i][0] = t;
  }
  for (int k = 0; k < (int)(logn - 1); k++) {
    for (int i = 0; i < (int)(n); i++) {
      if (dou_hotel[i][k] == INT_MAX) {
        dou_hotel[i][k + 1] == INT_MAX;
      } else {
        dou_hotel[i][k + 1] = dou_hotel[dou_hotel[i][k]][k];
      }
    }
  }
  for (int j = 0; j < (int)(Q); j++) {
    long long ind;
    long long ch = a[j];
    long long ans = 0;
    for (int i = logn - 1; i >= 0; i--) {
      if (i == 0)
        ans++;
      else if (dou_hotel[ch][i] >= b[j] && dou_hotel[ch][i - 1] < b[j]) {
        ans += pow(2, i - 1);
        ch = dou_hotel[ch][i - 1];
        i++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
