#include <bits/stdc++.h>
using namespace std;
long long table[100001][21];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> v;
  long long l;
  for (long long i = 0; i < n; i++) {
    long long k;
    cin >> k;
    v.push_back(k);
  }
  v.push_back(1e17);
  cin >> l;
  int k = 20;
  long long pointer = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = pointer; j <= n; j++) {
      if (v[j] - v[i] > l) {
        pointer = j;
        table[i][0] = j - 1;
        break;
      }
    }
  }
  for (long long j = 1; j <= k; j++) {
    for (long long i = 0; i <= n; i++)
      table[i][j] = table[table[i][j - 1]][j - 1];
  }
  long long q;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    long long answer = 0;
    while (a < b) {
      for (long long j = k; j >= 0; j--) {
        if (table[a][j] < b || j == 0) {
          answer = answer + (1 << j);
          a = table[a][j];
          break;
        }
      }
    }
    cout << answer << endl;
  }
  return 0;
}
