#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t N;
  cin >> N;
  vector<int64_t> x(N);
  for (int64_t i = (int64_t)(0); i < (int64_t)(N); i++) cin >> x[i];
  int64_t L, Q;
  cin >> L >> Q;
  vector<array<int64_t, 2>> ab(Q);
  for (int64_t i = (int64_t)(0); i < (int64_t)(Q); i++)
    cin >> ab[i][0] >> ab[i][1];
  for (int64_t i = (int64_t)(0); i < (int64_t)(Q); i++)
    for (int64_t j = (int64_t)(0); j < (int64_t)(2); j++) ab[i][j]--;
  int64_t len = 0;
  while ((1 << len) < N) len++;
  vector<vector<int64_t>> table(N, vector<int64_t>(len, 0));
  for (int64_t j = (int64_t)(0); j < (int64_t)(len); j++)
    table[N - 1][j] = N - 1;
  for (int64_t i = (int64_t)(0); i < (int64_t)(N - 1); i++) {
    int64_t lb = i + 1, ub = N;
    while (lb + 1 < ub) {
      const int64_t med = (lb + ub) / 2;
      const int64_t dist = x[med] - x[i];
      if (dist <= L)
        lb = med;
      else
        ub = med;
    }
    table[i][0] = lb;
  }
  for (int64_t j = (int64_t)(1); j < (int64_t)(len); j++)
    for (int64_t i = (int64_t)(0); i < (int64_t)(N - 1); i++) {
      table[i][j] = table[table[i][j - 1]][j - 1];
    }
  for (int64_t qq = (int64_t)(0); qq < (int64_t)(Q); qq++) {
    int64_t a = min(ab[qq][0], ab[qq][1]);
    int64_t b = max(ab[qq][0], ab[qq][1]);
    int64_t answer = 1;
    while (1) {
      int64_t n = 0;
      for (; table[a][n] < b; n++)
        ;
      if (n == 0) break;
      answer += (1 << (n - 1));
      a = table[a][n - 1];
    }
    cout << answer << endl;
  }
}
