#include <bits/stdc++.h>
using namespace std;
long long x[100003];
int mov[100003][20];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> x[i];
  long long L;
  int Q;
  cin >> L >> Q;
  for (int i = 0; i < n; ++i) {
    int lo = i, hi = n;
    while (hi - lo > 1) {
      int mid = lo + (hi - lo) / 2;
      if (x[mid] - x[i] > L)
        hi = mid;
      else
        lo = mid;
    }
    mov[i][0] = lo;
  }
  for (int j = 1; j < 20; ++j) {
    for (int i = 0; i < n; ++i) {
      mov[i][j] = mov[mov[i][j - 1]][j - 1];
    }
  }
  for (int i = 0; i < Q; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a > b) swap(a, b);
    int pos = a;
    long long ans = 0;
    while (pos < b) {
      int lo = -1, hi = 20;
      while (hi - lo > 1) {
        int mid = lo + (hi - lo) / 2;
        if (mov[pos][mid] >= b)
          hi = mid;
        else
          lo = mid;
      }
      ans += (1LL << (long long)hi);
      pos = mov[pos][hi];
    }
    cout << ans << endl;
  }
  return 0;
}
