#include <bits/stdc++.h>
using namespace std;
int n, a[200001], sum[200001], maxi[200001], q, dis, c, b, itr = 1,
                                                           reach[200001][18];
int main() {
  memset(reach, -1, sizeof reach);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> dis;
  for (int i = 1; i < n; i++) {
    int l = i + 1, r = n;
    while (l != r) {
      int mid = (l + r) / 2;
      if (a[mid] - a[i] < dis)
        l = mid + 1;
      else
        r = mid;
    }
    if (a[l] - a[i] > dis) l--;
    maxi[i] = l;
  }
  maxi[n] = n;
  for (int j = 0; j < 17; j++) {
    for (int i = 1; i <= n; i++) {
      if (j == 1) {
        reach[i][j] = maxi[i];
      } else {
        reach[i][j] = reach[reach[i][j - 1]][j - 1];
      }
    }
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int ans = 0;
    cin >> c >> b;
    if (c > b) swap(b, c);
    if (c == b) {
      cout << 0 << endl;
      continue;
    }
    for (int i = 17; i >= 0; i--) {
      if (reach[c][i] < b && reach[c][i] != -1) {
        c = reach[c][i];
        if (i) ans += 1 << (i - 1);
      }
    }
    cout << ans + 1 << endl;
  }
}
