#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  int l, q;
  cin >> l >> q;
  vector<int> dp[20];
  for (int i = 0; i < (20); i++) dp[i] = vector<int>(100005, -1);
  for (int i = 0; i < (n); i++) {
    dp[0][i] =
        distance(a.begin(), upper_bound((a).begin(), (a).end(), a[i] + l)) - 1;
  }
  for (int k = 0; k < (20); k++) {
    for (int i = 0; i < (n); i++) {
      if (dp[k][i] == -1) break;
      dp[k + 1][i] = dp[k][dp[k][i]];
    }
  }
  for (int i = 0; i < (q); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = 0;
    int day = 1;
    for (int _ = 0; _ < (19); _++) day *= 2;
    for (int j = 20 - 1; j >= 0; j--, day /= 2) {
      if (dp[j][a] == -1) continue;
      if (dp[j][a] <= b) {
        a = dp[j][a];
        ans += day;
      }
    }
    cout << ans << endl;
  }
}
