#include <bits/stdc++.h>
using namespace std;
int n, z;
long long t[111111];
int nex[50][111111];
int q;
long long che(int x) {
  long long l = x + 1, r = n, mid = (r + l) / 2;
  while (r - l > 1) {
    long long ab = t[mid] - t[x];
    if (ab > z)
      r = mid;
    else
      l = mid;
    mid = (r + l) / 2;
  }
  return l;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> t[i];
  cin >> z;
  for (int i = 0; i < n; i++) {
    nex[0][i] = che(i);
  }
  for (int i = 0; i < 40; i++) {
    for (int j = 0; j < n; j++) {
      if (nex[i][j] == n)
        nex[i + 1][j] = n;
      else
        nex[i + 1][j] = nex[i][nex[i][j]];
    }
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    long long l = 0, r = n, mid = (r + l) / 2;
    int tmp = a;
    while (r - l > 1) {
      tmp = a;
      for (int j = 0; j < 30; j++) {
        if ((1 << j) & mid) tmp = nex[j][tmp];
      }
      if (tmp >= b)
        r = mid;
      else
        l = mid;
      mid = (r + l) / 2;
    }
    cout << r << endl;
  }
  return 0;
}
