#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 7;
int x[N], dp[N], n, l;
int pr[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", x + i);
  }
  scanf("%d", &l);
  int cur = 1;
  for (int i = 2; i <= n; i++) {
    while (x[i] - x[cur] > l) {
      cur++;
    }
    pr[i] = cur;
    dp[i] = dp[cur] + 1;
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a > b) swap(a, b);
    int ans = dp[b] - dp[a];
    if (!ans) ans++;
    if (a < pr[b] && dp[a] == dp[pr[b]]) ans++;
    printf("%d\n", ans);
  }
}
