#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;
long long int N, M, K, H, W, L, R;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  vector<int> place(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> place[i];
  }
  cin >> M;
  cin >> K;
  vector<vector<int>> nx(N + 1, vector<int>(20, INT_MAX));
  int box = N;
  for (int i = N - 1; i >= 1; i--) {
    while (place[box] - place[i] > M) {
      box--;
    }
    nx[i][0] = box;
  }
  int two[20] = {};
  two[0] = 1;
  for (int i = 1; i < 20; i++) {
    two[i] = two[i - 1] * 2;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j < 20; j++) {
      if (i + nx[i][j - 1] > N) break;
      if (nx[i + nx[i][j - 1]][j - 1] == INT_MAX) break;
      nx[i][j] = nx[i + nx[i][j - 1]][j - 1];
    }
  }
  for (int i = 0; i < K; i++) {
    cin >> L >> R;
    if (L > R) swap(L, R);
    int ans = 0;
    for (int j = 19; j >= 0; j--) {
      if (nx[L][j] <= R) {
        L = nx[L][j];
        ans += two[j];
      }
    }
    if (L < R) {
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
