#include <bits/stdc++.h>
using namespace std;
int N;
long long x[100001];
long long L;
int Q;
int a[100001];
int b[100001];
int c[100001];
int main() {
  for (int i = 0; i < (100001); i++) {
    c[i] = 100001;
  }
  cin >> N;
  for (int i = 0; i < (N); i++) {
    cin >> x[i];
  }
  cin >> L >> Q;
  for (int i = 0; i < (Q); i++) {
    cin >> a[i] >> b[i];
  }
  int s = 0;
  int t = 0;
  while (1) {
    if (t > N || s > N) break;
    if (x[t] - x[s] <= L || (x[t] - x[s] <= 0)) {
      t++;
    } else {
      c[s] = t - 1;
      s++;
    }
  }
  for (int i = 0; i < (Q); i++) {
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) {
      swap(a[i], b[i]);
    }
    int temp = a[i];
    int count = 0;
    while (1) {
      count++;
      temp = c[temp];
      if (temp >= b[i]) {
        cout << count << endl;
        break;
      }
    }
  }
  cout << endl;
  return (0);
}
