#include <bits/stdc++.h>
using namespace std;
const int N = 300001;
int n, m, L;
int a[N];
struct edge {
  int x, y;
} b[N] = {};
int vis[N] = {};
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &L);
  int k = a[1] + L;
  for (int i = 1; i <= n; i++) {
    if (a[i] > k) {
      vis[i - 1] = 1;
      k = a[i - 1] + L;
    }
  }
  for (int i = 1; i <= n; i++) {
    vis[i] = vis[i - 1] + vis[i];
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    printf("%d\n", vis[y] - vis[x]);
  }
  return 0;
}
