#include <bits/stdc++.h>
using namespace std;
long long int lift[(long long int)1e5 + 10][20] = {0};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> dis(n);
  for (long long int i = 0; i < (long long int)(n); i++) cin >> dis[i];
  long long int j = 0;
  long long int l;
  cin >> l;
  for (long long int i = 0; i < (long long int)(n); i++) {
    while (j < dis.size() - 1 && dis[j + 1] <= dis[i] + l) {
      j++;
    }
    lift[i][0] = j;
  }
  for (long long int i = 1; i <= 16; i++) {
    for (long long int j = 0; j < (long long int)(n); j++) {
      lift[j][i] = lift[lift[j][i - 1]][i - 1];
    }
  }
  long long int q;
  cin >> q;
  long long int i;
  for (long long int xx = 0; xx < (long long int)(q); xx++) {
    cin >> i >> j;
    if (j < i) swap(i, j);
    i--, j--;
    long long int ans = 0;
    long long int bit = 16;
    while (bit >= 0 && i < j) {
      if (lift[i][bit] <= j) {
        i = lift[i][bit];
        ans += (1 << bit);
      }
      bit--;
    }
    cout << ans << "\n";
  }
}
