#include <bits/stdc++.h>
using namespace std;
int n, l, q, a[100005], p[20][100005], pow2[20];
inline bool getBit(unsigned int x, unsigned int p) { return (x >> p) & 1; }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  scanf("%d %d", &l, &q);
  int pos = n - 1;
  for (int i = n - 1; i >= 0; i--) {
    while (a[pos] - a[i] > l) pos--;
    p[0][i] = pos;
  }
  pow2[0] = 1;
  for (int i = 1; i < 20; i++) {
    pow2[i] = pow2[i - 1] * 2;
    for (int j = 0; j < n; j++) p[i][j] = p[i - 1][p[i - 1][j]];
  }
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--, b--;
    if (a > b) swap(a, b);
    int left = 0, right = n;
    while (left <= right) {
      int mid = (left + right) / 2, pos = a;
      for (int i = 19; i >= 0; i--)
        if (getBit(mid, i)) pos = p[i][pos];
      if (pos >= b)
        right = mid - 1;
      else
        left = mid + 1;
    }
    printf("%d\n", left);
  }
  return 0;
}
