#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int LOG = 20;
int n, L, q;
int to[N][LOG], a[N];
void pre() {
  memset(to, -1, sizeof to);
  for (int i = 0; i < n - 1; i++) {
    int idx = lower_bound(a, a + n, a[i] + L) - a;
    if (idx == n || a[idx] > a[i] + L) {
      idx--;
    }
    assert(idx > i);
    to[i][0] = idx;
  }
  for (int j = 1; j < LOG; j++) {
    for (int i = 0; i < n; i++) {
      if (to[i][j - 1] != -1) {
        to[i][j] = to[to[i][j - 1]][j - 1];
      }
      if (to[i][j] == -1) {
        to[i][j] = n;
      }
    }
  }
}
int getKth(int u, int k) {
  for (int i = 0; k; i++) {
    if (k & 1) {
      u = to[u][i];
    }
    k >>= 1;
  }
  return u;
}
int f(int from, int to) {
  int L = 0, R = n, ans = n;
  while (L <= R) {
    int mid = (L + R) / 2;
    if (getKth(from, mid) >= to) {
      ans = mid;
      R = mid - 1;
    } else {
      L = mid + 1;
    }
  }
  return ans;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> L >> q;
  pre();
  while (q--) {
    int from, to;
    cin >> from >> to;
    from--, to--;
    if (from > to) {
      swap(from, to);
    }
    cout << f(from, to) << '\n';
  }
  return 0;
}
