#include <bits/stdc++.h>
using namespace std;
int hotel[100005];
int jump[100005][20];
int solve(int u, int v) {
  if (u == v) return 0;
  int ans = 0;
  for (int i = 17; i >= 0; i--) {
    if (jump[u][i] < v) {
      u += jump[u][i];
      ans += (1 << i);
    }
  }
  return ans + 1;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k, q;
  cin >> n;
  hotel[n + 1] = 2e9;
  for (int i = 1; i <= n; i++) {
    cin >> hotel[i];
  }
  cin >> k;
  cin >> q;
  for (int i = 1; i <= n; i++) {
    int p = upper_bound(hotel, hotel + n + 2, hotel[i] + k) - hotel;
    jump[i][0] = p - 1;
  }
  for (int j = 1; j < 18; j++) {
    for (int i = 1; i <= n; i++) {
      jump[i][j] = jump[jump[i][j - 1]][j - 1];
    }
  }
  while (q--) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    cout << solve(u, v) << '\n';
  }
}
