#include <bits/stdc++.h>
using namespace std;
int n, step, k;
int x[100002];
vector<int> sons[100002];
int level[100002];
void dfs(int node) {
  for (int u : sons[node]) {
    level[u] = level[node] + 1;
    dfs(u);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i];
  cin >> step >> k;
  for (int i = 1; i < n; i++) {
    int l = i, r = n;
    while (l < r) {
      int mid = (l + r + 1) / 2;
      if (x[mid] - x[i] > step)
        r = mid - 1;
      else
        l = mid;
    }
    sons[l].push_back(i);
  }
  dfs(n);
  while (k--) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    cout << level[a] - level[b] << "\n";
  }
  return 0;
}
