#include <bits/stdc++.h>
using namespace std;
int n, A[100005], l, q, x, y, sag[23][100005], tut;
vector<int> v;
int bs(int x) {
  int bas = 1, son = n;
  while (bas <= son) {
    int mid = (bas + son) / 2;
    if (A[mid] == x) return mid;
    if (A[mid] > x)
      son = mid - 1;
    else
      bas = mid + 1;
  }
  return son;
}
void init() {
  for (int i = 1; i <= n; i++) {
    if (A[i] + l >= A[n])
      sag[0][i] = n;
    else
      sag[0][i] = bs(A[i] + l);
  }
}
void init2() {
  for (int i = 1; i <= 20; i++) {
    for (int j = 1; j <= n; j++) {
      sag[i][j] = sag[i - 1][sag[i - 1][j]];
    }
  }
  for (int i = 1; i <= 20; i++) {
    if (sag[i][1] <= n) tut = i;
    if (sag[i][1] >= n) break;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  scanf("%d %d", &l, &q);
  init();
  init2();
  for (int i = 1; i <= q; i++) {
    scanf("%d %d", &x, &y);
    if (x > y) swap(x, y);
    int cev = 0;
    while (x < y) {
      int bas = 0, son = tut;
      while (bas <= son) {
        int mid = (bas + son) / 2;
        if (sag[mid][x] >= y)
          son = mid - 1;
        else
          bas = mid + 1;
      }
      cev += (1 << bas);
      x = sag[bas][x];
    }
    printf("%d\n", cev);
  }
  return 0;
}
