#include <bits/stdc++.h>
using namespace std;
int h[100000 + 1];
int farthest[100000 + 1][20 + 1];
int lg[100000 + 1];
int maximum_distance(int i, int d) {
  int j = i;
  while (d > 0) {
    j = farthest[j][lg[d]];
    d -= (1 << lg[d]);
  }
  return j;
}
int b_search(int a, int b) {
  int L = 1;
  int R = 100000;
  while (R - L > 1) {
    int M = (L + R) / 2;
    if (maximum_distance(a, M) >= b)
      R = M;
    else
      L = M;
  }
  if (maximum_distance(a, L) >= b)
    return L;
  else
    return R;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int x = 0; x <= 20; x++)
    for (int n = (1 << x); n <= 100000 && n < (1 << (x + 1)); n++) lg[n] = x;
  int n, L;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> h[i];
  cin >> L;
  for (int i = 1; i <= n; i++) {
    int j;
    for (j = i; j <= n && h[j] - h[i] <= L; j++)
      ;
    farthest[i][0] = j - 1;
  }
  for (int x = 1; x <= 20; x++)
    for (int i = 1; i <= n; i++)
      farthest[i][x] = farthest[farthest[i][x - 1]][x - 1];
  int Q;
  cin >> Q;
  while (Q--) {
    int a, b;
    cin >> a >> b;
    cout << b_search(min(a, b), max(a, b)) << '\n';
  }
  return 0;
}
