#include <bits/stdc++.h>
long long arr[100005];
int dis[100005];
long long l;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
  }
  scanf("%lld", &l);
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int j = i + 1; j <= n; j++) {
      if (arr[j] - arr[i] <= l) {
        cnt++;
      } else {
        break;
      }
    }
    dis[i] = cnt;
  }
  int Q;
  scanf("%d", &Q);
  int s, t;
  for (int i = 0; i < Q; i++) {
    scanf("%d%d", &s, &t);
    if (s > t) {
      int temp = s;
      s = t;
      t = temp;
    }
    int res = 0;
    int cur = s;
    while (cur < t) {
      cur += dis[cur];
      res++;
    }
    printf("%d\n", res);
  }
}
