#include <bits/stdc++.h>
int x[100005] = {}, dp[100005][20], lg[20] = {1};
int main() {
  int n, m, q, a, b, temp, ans, d, last, k;
  scanf("%d", &n);
  last = n;
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  scanf("%d %d", &m, &q);
  for (int i = 1; i < 20; i++) lg[i] = lg[i - 1] * 2;
  for (int i = n; dp[1][0] == 0; i--) {
    d = x[i] - m;
    if (x[last] < d) continue;
    for (int j = last; j >= 1 && x[j] >= d; j--, last--) dp[j][0] = i;
  }
  for (int j = 1; j <= 16; j++)
    for (int i = 1; i <= n; i++) dp[i][j] = dp[dp[i][j - 1]][j - 1];
  while (q > 0) {
    q--;
    ans = 0;
    scanf("%d %d", &a, &b);
    if (a > b) {
      temp = a;
      a = b;
      b = temp;
    }
    while (a < b) {
      for (k = 0; k <= 16; k++)
        if (dp[a][k] >= b) break;
      ans += lg[k];
      a = dp[a][k];
    }
    printf("%d\n", ans);
  }
  return 0;
}
