#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < (n); i++) cin >> x[i];
  int l;
  cin >> l;
  const int INF = 1e6;
  vector<vector<int>> table(n, vector<int>(21, INF));
  int r = 0;
  for (int i = 0; i < (n); i++) {
    while (1) {
      if (r == n - 1) break;
      if (x[r + 1] - x[i] <= l)
        r++;
      else
        break;
    }
    table[i][0] = r;
  }
  for (int j = 0; j < (20); j++)
    for (int i = 0; i < (n); i++) {
      if (table[i][j] == INF)
        table[i][j + 1] = INF;
      else
        table[i][j + 1] = table[table[i][j]][j];
    }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int ans = 0;
    for (int i = 20; i >= 0; i--) {
      if (table[a][i] < b) {
        a = table[a][i], ans += 1 << i;
      }
    }
    cout << ans << endl;
  }
}
