#include <bits/stdc++.h>
int a[100010], b[100010], x[100010], r[100010][20];
int intcmp(const void *a, const void *b) {
  int c = *(int *)a - *(int *)b;
  if (c > 0)
    return 1;
  else if (!c)
    return 0;
  else
    return -1;
}
int *binary(int *seq, const int len, const int key) {
  int left, mid, right;
  left = 0;
  right = len - 1;
  while (left <= right) {
    mid = (left + right) / 2;
    if (*(seq + mid) >= key)
      right = mid - 1;
    else
      left = mid + 1;
  }
  return seq + mid;
}
int main() {
  int D, from, i, j, k, key, L, left, mid, N, *ptr, Q, right, to;
  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &x[i]);
  scanf("%d%d", &L, &Q);
  for (i = 0; i < Q; i++) scanf("%d%d", &a[i], &b[i]);
  for (i = 0; i < N - 1; i++) {
    j = 0;
    key = x[i] + L;
    ptr = binary(x, N, key);
    r[i][0] = (ptr - x) + 1;
  }
  r[N - 1][0] = N;
  for (k = 1; k < 20; k++) {
    for (i = 0; i < N - 1; i++) {
      r[i][k] = r[r[i][k - 1] - 1][k - 1];
    }
    r[N - 1][k] = N;
  }
  for (i = 0; i < Q; i++) {
    D = 0;
    if (a[i] > b[i]) {
      from = b[i];
      to = a[i];
      left = 0;
      right = 19;
      k = N + 10;
      while (left <= right) {
        mid = (left + right) / 2;
        if (r[from - 1][mid] >= to) {
          if (k > mid) k = mid;
          right = mid - 1;
        } else {
          if (k > mid) k = mid;
          left = mid + 1;
        }
      }
      j = 1;
      while (--k > 0) j *= 2;
      D += j;
    } else {
      from = a[i];
      to = b[i];
      left = 0;
      right = 19;
      k = N + 10;
      while (left <= right) {
        mid = (left + right) / 2;
        if (r[from - 1][mid] >= to) {
          if (k > mid) k = mid;
          right = mid - 1;
        } else {
          if (k > mid) k = mid;
          left = mid + 1;
        }
      }
      j = 1;
      while (--k > 0) j *= 2;
      D += j;
    }
    printf("%d\n", D);
  }
  return 0;
}
