#include <bits/stdc++.h>
using namespace std;
int n, L, Q;
const int maxn = 1e5 + 5;
int x[maxn];
int st[maxn][20];
void init() {
  for (int i = 1; i <= n + 1; i++) {
    int l = i, r = n + 1;
    while (l < r) {
      int mid = (l + r + 1) / 2;
      if (x[mid] - x[i] <= L) {
        l = mid;
      } else {
        r = mid - 1;
      }
    }
    st[i][0] = l;
  }
  for (int len = 1; (1 << len) <= n + 1; len++) {
    int j = (1 << len);
    for (int i = 1; i <= n + 1; i++) {
      if (i + j - 1 <= n)
        st[i][len] = st[st[i][len - 1]][len - 1];
      else
        st[i][len] = st[i][len - 1];
    }
  }
}
int cal(int a, int len) {
  for (int i = 0; i < 20; i++) {
    if (len & (1 << i)) {
      a = st[a][i];
    }
  }
  return a;
}
int query(int a, int b) {
  int l = 0, r = n;
  while (l < r) {
    int mid = (l + r) / 2;
    if (cal(a, mid) >= b) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  return l;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
  }
  cin >> L;
  x[n + 1] = x[n] + 1;
  init();
  cin >> Q;
  for (int i = 1; i <= Q; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    printf("%d\n", query(a, b));
  }
  return 0;
}
