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