#include <bits/stdc++.h>
using namespace std;
const int S = 1e5;
vector<int> m[S];
int x[S];
int N, L;
int g(int a, int k) {
  if (k == 0) {
    return a;
  }
  if (m[a].size() == 0) {
    int v = upper_bound(x + a, x + N, x[a] + L) - x - 1;
    m[a].push_back(v);
  }
  int e = 0;
  int j = 1;
  while (a % (2 * j) == 0 && 2 * j <= k) {
    if (m[a].size() == e + 1) {
      int v = g(m[a][e], j);
      if (m[a][e] == N) {
        return N;
      }
      m[a].push_back(v);
    }
    e++;
    j *= 2;
  }
  return g(m[a][e], k - j);
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L;
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      swap(a, b);
    }
    int low = 0;
    int hi = S;
    while (low + 1 < hi) {
      int mid = (low + hi) / 2;
      int v = g(a, mid);
      if (b <= v) {
        hi = mid;
      } else {
        low = mid;
      }
    }
    cout << hi << endl;
  }
  return 0;
}
