#include <bits/stdc++.h>
using namespace std;
long long a[100005], n;
int reach[100005];
int bs(long long x) {
  int l = 1, r = n;
  while (l <= r) {
    if (l == r - 1) {
      break;
    }
    int mid = (l + r) / 2;
    if (a[mid] > x) {
      r = mid;
    } else {
      l = mid;
    }
  }
  return l;
}
int bs2(long long x) {
  int l = 1, r = n;
  while (l <= r) {
    if (l == r - 1) break;
    int mid = (l + r) / 2;
    if (a[mid] > x) {
      l = mid;
    } else {
      r = mid;
    }
  }
  return l;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long l;
  cin >> l;
  int q;
  cin >> q;
  while (q--) {
    int a1, b;
    cin >> a1 >> b;
    if (a1 > b) {
      swap(a1, b);
    }
    int start = a1, cnt = 0;
    while (start < b) {
      start = bs(a[start] + l);
      cnt++;
    }
    cout << cnt << "\n";
  }
}
