#include <bits/stdc++.h>
using namespace std;
const int N = 2e6;
int n;
int L;
int T;
int pos[N];
int near[N];
int dp[N];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) pos[i] = read();
  L = read();
  near[1] = 1;
  for (int i = 2; i <= n; i++) {
    int temp = pos[i] - L;
    near[i] = lower_bound(pos + near[i - 1], pos + i + 1, temp) - pos;
  }
  for (int i = 2; i <= n; i++) dp[i] = dp[near[i]] + 1;
  T = read();
  while (T--) {
    int st = read(), en = read();
    if (st == en)
      puts("0");
    else
      printf("%d\n", abs(dp[en] - dp[st]) ? abs(dp[en] - dp[st]) : 1);
  }
  return 0;
}
