#include <bits/stdc++.h>
using namespace std;
int n, l, q;
int x[100010];
int cango[100010][31][2] = {};
void calc() {
  cango[0][0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int cnt = cango[i - 1][0][0];
    while (cnt <= n && x[cnt] - x[i] <= l) cnt++;
    cnt--;
    cango[i][0][0] = cnt;
  }
  cango[n + 1][0][1] = n;
  for (int i = n; i >= 1; i--) {
    int cnt = cango[i + 1][0][1];
    while (cnt >= 1 && x[i] - x[cnt] <= l) cnt--;
    cnt++;
    cango[i][0][1] = cnt;
  }
  for (int i = 1; i <= 30; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 0; k < 2; k++) {
        cango[j][i][k] = cango[cango[j][i - 1][k]][i - 1][k];
      }
    }
  }
}
int cango_place(int s, long long int dnum, int l_or_r) {
  int nowplace = s;
  for (int i = 30; i >= 0; i--) {
    long long int tmp = pow(2, i);
    if (dnum >= tmp) {
      dnum -= tmp;
      nowplace = cango[nowplace][i][l_or_r];
    }
  }
  return nowplace;
}
int solve(int s, int e) {
  int l = 0, r = 1000000000;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (s > e) {
      if (cango_place(s, mid, (s > e)) <= e)
        r = mid;
      else
        l = mid;
    } else {
      if (cango_place(s, mid, (s > e)) >= e)
        r = mid;
      else
        l = mid;
    }
  }
  return r;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  cin >> l;
  calc();
  cin >> q;
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    cout << solve(a, b) << endl;
  }
  return 0;
}
