#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
int N, L, Q;
vector<int> X;
int calc(int a, int b) {
  int now = a;
  int res = 0;
  while (true) {
    if (now >= b) {
      break;
    }
    now = distance(X.begin(), upper_bound((X).begin(), (X).end(), X[now] + L)) -
          1;
    res += 1;
  }
  return res;
}
int main(int argc, char const* argv[]) {
  cin >> N;
  for (int i = 0; i < (N); i++) {
    int x;
    cin >> x;
    X.push_back(x);
  }
  cin >> L;
  cin >> Q;
  for (int q = 0; q < (Q); q++) {
    int a, b;
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    a -= 1;
    b -= 1;
    cout << calc(a, b) << endl;
  }
  return 0;
}
