#include <bits/stdc++.h>
using namespace std;
int N;
int x[100010];
int L, Q;
int a[100010];
int b[100010];
int memo[100010][18];
int g(int a, int r) {
  if (memo[a][r] != -1) return memo[a][r];
  int ans = 0;
  if (a == N - 1) {
    ans = N - 1;
  } else if (r == 0) {
    int now = a;
    while (now + 1 < N && x[now + 1] - x[a] <= L) {
      now++;
    }
    ans = now;
  } else {
    ans = g(g(a, r - 1), r - 1);
  }
  return memo[a][r] = ans;
}
int minimum(int a, int b) {
  if (b <= a) return 0;
  int x = 1;
  while (g(a, x) < b) {
    x++;
  }
  x -= 1;
  return (1 << x) + minimum(g(a, x), b);
}
int main() {
  cin >> N;
  for (auto i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L >> Q;
  for (auto i = 0; i < Q; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  fill(&memo[0][0], &memo[0][0] + 100010 * 18, -1);
  for (auto i = 0; i < Q; i++) {
    cout << minimum(a[i], b[i]) << endl;
  }
}
