#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> hotels(n);
  for (int i = 0; i < n; i++) cin >> hotels[i];
  hotels.push_back(hotels.back() + 1);
  int l;
  cin >> l;
  vector<vector<int>> move(n + 1, vector<int>(25));
  for (int i = 0; i <= n; i++) {
    move[i][0] = upper_bound(hotels.begin(), hotels.end(), hotels[i] + l) -
                 hotels.begin() - 1;
  }
  for (int j = 1; j < 25; j++) {
    for (int i = 0; i <= n; i++) {
      move[i][j] = move[move[i][j - 1]][j - 1];
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int from, to;
    cin >> from >> to;
    from--, to--;
    if (from > to) swap(from, to);
    int ret = 0;
    for (int j = 24; j >= 0; j--) {
      if (move[from][j] <= to) {
        from = move[from][j];
        ret += 1 << j;
      }
    }
    cout << ret << endl;
  }
  return 0;
}
