#include <bits/stdc++.h>
using namespace std;
inline long toInt(string s) {
  long v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
long long pw(long long x, long long y) {
  long long ans = 1;
  for (long long i = 0; i < y; i++) {
    ans = ans * x;
  }
  return ans;
}
long long factorial(long long x) {
  long long ans = 1;
  for (int i = 1; i < x + 1; i++) {
    ans = ans * i;
  }
  return ans;
}
long long combination(long long x, long long y) {
  return factorial(x) / factorial(y) / factorial(x - y);
}
long long permutation(long long x, long long y) {
  return factorial(x) / factorial(x - y);
}
int main() {
  long long n;
  cin >> n;
  vector<long long> x(n);
  for (long long i = 0; i < n; i++) {
    cin >> x[i];
  }
  long long l;
  cin >> l;
  long long q;
  cin >> q;
  vector<long long> a(q), b(q);
  for (long long i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
  }
  vector<long long> right(n);
  for (long long i = 0; i < n - 1; i++) {
    long long ll = i;
    long long rr = n - 1;
    while (rr - ll != 0 && rr - ll != 1) {
      if (x[(ll + rr) / 2] <= x[i] + l) {
        ll = (ll + rr) / 2;
      } else {
        rr = (ll + rr) / 2;
      }
    }
    if (rr - ll == 0) {
      right[i] = rr;
    } else {
      if (x[rr] <= x[i] + l) {
        right[i] = rr;
      } else {
        right[i] = ll;
      }
    }
  }
  vector<vector<long long>> right2(n);
  for (long long i = 0; i < n - 1; i++) {
    long long current = i;
    while (right[current] < n - 1) {
      current = right[current];
      right2[i].push_back(current);
    }
    right2[i].push_back(n - 1);
    right2[i].push_back(n - 1);
  }
  for (long long i = 0; i < q; i++) {
    long long current = min(a[i] - 1, b[i] - 1);
    long long goal = max(a[i] - 1, b[i] - 1);
    long long k;
    long long ans = 0;
    if (goal == n - 1) {
    } else {
      while (current != goal) {
        k = 0;
        while (right2[current][k] <= goal) {
          k++;
        }
        k--;
        current = right2[current][k];
        ans += k + 1;
      }
      cout << ans << endl;
    }
  }
}
