#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;
int n, L, q;
int a[N];
deque<pair<int, int> > dq;
deque<int> g[N];
int dfs(int v, int r, int cnt = 0) {
  if (v >= r) return cnt;
  for (int i = 0; i < g[v].size(); i++) {
    return dfs(g[v][i], r, cnt + 1);
  }
}
map<int, int> u[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> L >> q;
  dq.push_front(make_pair(a[n], n));
  for (int i = n - 1; i >= 1; i--) {
    int pos = upper_bound(dq.begin(), dq.end(), make_pair(a[i] + L, n + 1)) -
              dq.begin() - 1;
    g[i].push_front(dq[pos].second);
    dq.push_front(make_pair(a[i], i));
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    if (l > r) swap(l, r);
    if (u[l][r]) {
      cout << u[l][r] << endl;
      continue;
    }
    u[l][r] = dfs(l, r);
    cout << u[l][r] << endl;
  }
}
