#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> x, rx;
int L;
vector<vector<int>> dp, rdp;
void init() {
  rx = x;
  reverse(rx.begin(), rx.end());
  int latte = rx[0];
  for (int i = 0; i < N; ++i) {
    rx[i] = latte - rx[i];
  }
  dp.assign(17, vector<int>(N));
  rdp.assign(17, vector<int>(N));
  for (int l = 0, r = 0; l < N; ++l) {
    while (r < N && x[r] - x[l] <= L) r++;
    dp[0][l] = r - 1;
  }
  for (int l = 0, r = 0; l < N; ++l) {
    while (r < N && rx[r] - rx[l] <= L) r++;
    rdp[0][l] = r - 1;
  }
  for (int i = 0; i + 1 < 17; ++i) {
    for (int j = 0; j < N; ++j) {
      dp[i + 1][j] = dp[i][dp[i][j]];
      rdp[i + 1][j] = rdp[i][rdp[i][j]];
    }
  }
}
int ans(int a, int b) {
  if (a < b) {
    a--, b--;
    int res = 0;
    while (a < b) {
      for (int i = 1; i < 17; ++i) {
        if (dp[i][a] == b) {
          res += (1 << i);
          a = dp[i][a];
          break;
        }
        if (dp[i][a] > b) {
          res += (1 << (i - 1));
          a = dp[i - 1][a];
          break;
        }
      }
    }
    if (a != b) res--;
    return res;
  } else {
    a = N - a - 1;
    b = N - b - 1;
    int res = 0;
    while (a < b) {
      for (int i = 1; i < 17; ++i) {
        if (rdp[i][a] == b) {
          res += (1 << i);
          a = rdp[i][a];
          break;
        }
        if (rdp[i][a] > b) {
          res += (1 << (i - 1));
          a = rdp[i - 1][a];
          break;
        }
      }
    }
    if (a != b) res--;
    return res;
  }
}
int main() {
  cin >> N;
  x.resize(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  cin >> L;
  init();
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    cout << ans(a, b) << endl;
  }
}
