#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
int main() {
  static int N;
  static int x[100010];
  static int L;
  static int Q;
  static int a[100010], b[100010];
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &x[i]);
  }
  scanf("%d%d", &L, &Q);
  for (int i = 1; i <= Q; i++) {
    scanf("%d%d", &a[i], &b[i]);
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  x[N + 1] = 1000000001;
  static int nex[100010][20];
  for (int i = 1; i <= N; i++) {
    nex[i][0] = (upper_bound(x + i, x + N + 2, x[i] + L) - x) - 1;
  }
  for (int j = 1; j <= 19; j++) {
    for (int i = 1; i <= N; i++) {
      nex[i][j] = nex[nex[i][j - 1]][j - 1];
    }
  }
  for (int loop = 1; loop <= Q; loop++) {
    int loc = a[loop];
    int ret = 0;
    for (int j = 19; j >= 0; j--) {
      if (nex[loc][j] <= b[loop]) {
        loc = nex[loc][j];
        ret += 1 << j;
      }
    }
    printf("%d\n", ret);
  }
}
