#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000000 + 7;
int N;
int log_N;
vector<vector<int>> parent;
vector<long long> x;
long long L;
long long query(int a, int b) {
  if (a == b) {
    return 0;
  }
  int ret = 0;
  for (int k = log_N; k >= 0; k--) {
    int next = parent[k][a];
    if (next > b) continue;
    if (next == b) {
      ret += pow(2, k);
      break;
    } else {
      ret += pow(2, k);
      a = parent[k][a];
    }
  }
  return ret;
}
int main() {
  cout << setprecision(10);
  cin >> N;
  log_N = floor(log2(N));
  x.assign(N, 0);
  parent.assign(log_N + 1, vector<int>(N));
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L;
  cerr << "L: " << L << endl;
  for (int i = 0; i < N; i++) {
    auto itr = upper_bound(x.begin(), x.end(), x[i] + L);
    int index = itr - x.begin() - 1;
    parent.at(0).at(i) = index;
  }
  for (int k = 0; k < log_N; k++) {
    for (int i = 0; i < N; i++) {
      if (parent[k][i] == -1) {
        parent[k + 1][i] = -1;
      } else {
        parent[k + 1][i] = parent[k][parent[k][i]];
      }
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    tmp1--;
    tmp2--;
    if (tmp1 > tmp2) swap(tmp1, tmp2);
    cout << query(tmp1, tmp2) << endl;
  }
}
