#include <bits/stdc++.h>
void run(void) {
  int32_t n;
  scanf("%" SCNi32, &n);
  int32_t *x = (int32_t *)calloc(n, sizeof(int32_t));
  for (int32_t i = 0; i < n; ++i) {
    scanf("%" SCNi32, x + i);
  }
  int32_t l;
  scanf("%" SCNi32, &l);
  int32_t bit = 0;
  while ((1 << bit) < n) bit++;
  int32_t *dp = (int32_t *)calloc(n * bit, sizeof(int32_t));
  for (int32_t i = 0, j = 0; i < n; ++i) {
    while (j < n && x[j] - x[i] <= l) j++;
    dp[((i)*bit + (0))] = j - 1;
  }
  for (int32_t k = 1; k < bit; ++k) {
    for (int32_t i = 0; i < n; ++i) {
      int32_t a = dp[((i)*bit + (k - 1))];
      dp[((i)*bit + (k))] = dp[((a)*bit + (k - 1))];
    }
  }
  int32_t q;
  scanf("%" SCNi32, &q);
  while (q--) {
    int32_t a, b;
    scanf("%" SCNi32 "%" SCNi32, &a, &b);
    a--;
    b--;
    if (a > b) {
      int32_t s = b;
      b = a;
      a = s;
    }
    int32_t ans = 0;
    int32_t j = bit - 1;
    while (a < b) {
      while (j > 0 && dp[((a)*bit + (j))] > b) --j;
      ans += 1 << j;
      a = dp[((a)*bit + (j))];
    }
    printf("%" PRIi32 "\n", ans);
  }
}
int main(void) {
  run();
  return 0;
}
