#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
int main() {
  int n, L, q, x[112345], a[112345], b[112345];
  cin >> n;
  for (int i = (0); i < (n); i++) cin >> x[i];
  cin >> L >> q;
  for (int i = (0); i < (q); i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  int d[20][112345];
  for (int i = 0; i < n; i++) {
    int l = i;
    int r = n;
    while (r - l > 1) {
      int mid = (r + l) / 2;
      if (x[mid] - x[i] <= L)
        l = mid;
      else
        r = mid;
    }
    d[0][i] = l;
  }
  for (int j = 1; j < 20; j++)
    for (int i = 0; i < n; i++) d[j][i] = d[j - 1][d[j - 1][i]];
  for (int i = (0); i < (q); i++) {
    long long res = 0;
    int c = a[i];
    int l = 19;
    while (true) {
      if (c == b[i]) break;
      while (true) {
        if (d[l][c] <= b[i]) break;
        l--;
      }
      res += 1 << l;
      c = d[l][c];
    }
    cout << res << endl;
  }
  return 0;
}
