#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];
  for (int i = 2; i <= n; i++) {
    vis[i] = vis[i - 1];
    if (k < a[i]) vis[i]++, k = a[i - 1] + L;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    if (vis[y] != vis[x] && a[x] != a[y])
      printf("%d\n", vis[y] - vis[x]);
    else
      puts("1");
  }
  return 0;
}
