#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d\n", &N);
  vector<long long> x(N);
  map<long long, int> xmap;
  for (int i = 0; i < N; ++i) {
    long long xi;
    scanf("%lld", &xi);
    getchar();
    x[i] = xi;
    xmap.emplace(xi, i);
  }
  long long L;
  scanf("%lld\n", &L);
  vector<int> left(N);
  vector<int> right(N);
  for (int i = 0; i < N; ++i) {
    left[i] = xmap.lower_bound(x[i] - L)->second;
    right[i] = xmap.upper_bound(x[i] + L)->second - 1;
  }
  int Q;
  scanf("%d\n", &Q);
  for (int q = 0; q < Q; ++q) {
    int a, b;
    scanf("%d %d\n", &a, &b);
    --a;
    --b;
    int hotel = a;
    if (a < b) {
      for (long long day = 1;; ++day) {
        if (b <= right[hotel]) {
          printf("%lld\n", day);
          break;
        }
        hotel = right[hotel];
      }
    } else {
      for (long long day = 1;; ++day) {
        if (left[hotel] <= b) {
          printf("%lld\n", day);
          break;
        }
        hotel = left[hotel];
      }
    }
  }
}
