#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
vector<int> X;
int L;
int memo[1000][1000];
int dfs(int from, int to) {
  if (from >= to) return 0;
  int& res = memo[from][to];
  if (res != -1) return res;
  int now = X[from];
  int nxt = upper_bound(X.begin(), X.end(), now + L) - X.begin() - 1;
  return res = dfs(nxt, to) + 1;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  assert(N <= 1000);
  X.resize(N);
  for (int i = (int)(0); i < (int)(N); ++i) cin >> X[i];
  int Q;
  cin >> L >> Q;
  assert(Q <= 1000);
  memset(memo, -1, sizeof(memo));
  for (int i = (int)(0); i < (int)(Q); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a > b) swap(a, b);
    cout << dfs(a, b) << '\n';
  }
  return 0;
}
