#include <bits/stdc++.h>
using namespace std;
using i64 = long long int;
int main() {
  int n;
  cin >> n;
  vector<i64> v;
  for (int i = 0; i < n; ++i) {
    i64 x;
    cin >> x;
    v.push_back(x);
  }
  i64 l, q;
  cin >> l >> q;
  vector<pair<int, int>> lim;
  for (int i = 0; i < n; ++i) {
    int left = -1, right = i - 1;
    while (abs(right - left) > 1) {
      int mid = (right + left) / 2;
      if (abs(v[mid] - v[i]) <= l)
        right = mid;
      else
        left = mid;
    }
    int first = right;
    left = i + 1;
    right = n;
    while (abs(right - left) > 1) {
      int mid = (right + left) / 2;
      if (abs(v[mid] - v[i]) <= l)
        left = mid;
      else
        right = mid;
    }
    int second = left;
    lim.push_back(make_pair(first, second));
  }
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (b < a) swap(a, b);
    int ans = 0;
    while (b > lim[a].second) {
      a = lim[a].second;
      ans++;
    }
    ans++;
    cout << ans << endl;
  }
  return 0;
}
