#include <bits/stdc++.h>
int x_go_max[15][100000];
int a[100000], b[100000];
int main(void) {
  int n, i, j;
  scanf("%d", &n);
  int x[100000];
  for (i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  int l;
  scanf("%d", &l);
  int q;
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d%d", &a[i], &b[i]);
    a[i]--;
    b[i]--;
  }
  for (i = 0; i < n; i++) {
    if (x[n - 1] - x[i] <= l) {
      x_go_max[0][i] = n - 1;
      continue;
    }
    int left = i + 1;
    int right = n;
    while (right - left > 1) {
      int mid = (right - left) / 2 + left;
      if (x[mid] - x[i] <= l) {
        left = mid;
      } else {
        right = mid;
      }
    }
    x_go_max[0][i] = left;
  }
  for (i = 1; i < 15; i++) {
    for (j = 0; j < n; j++) {
      x_go_max[i][j] = x_go_max[i - 1][x_go_max[i - 1][j]];
    }
  }
  for (i = 0; i < q; i++) {
    int ans = 0;
    int c = a[i] > b[i] ? b[i] : a[i];
    int d = a[i] > b[i] ? a[i] : b[i];
    for (j = 14; j >= 0; j--) {
      if (x_go_max[j][c] < d) {
        c = x_go_max[j][c];
        ans += 1 << j;
      }
    }
    printf("%d\n", ans + 1);
  }
  return 0;
}
