#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100002;
int N, L, Q;
int x[MAXN] = {0};
int a, b;
vector<int> dis[MAXN];
void solve() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> x[i];
  cin >> L;
  for (int i = 1; i <= N; i++) {
    dis[i].push_back(i);
    int lastNode = x[i];
    int lastDis = 0;
    for (int j = i + 1; j <= N; j++) {
      if (x[j] - lastNode <= L) {
        ;
      } else {
        lastDis += 1;
        lastNode = x[j - 1];
        dis[i].push_back(j - 1);
      }
    }
  }
  cin >> Q;
  for (int i = 1; i <= Q; i++) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    auto it = lower_bound(dis[a].begin(), dis[a].end(), b);
    cout << (int)(it - dis[a].begin()) << endl;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  solve();
  return 0;
}
