#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void priv(vector<T> a) {
  for (int i = 0; i < a.size(); i++) {
    cerr << a[i] << ((i == a.size() - 1) ? "\n" : " ");
  }
}
long long gcd(long long a, long long b) {
  int c = max(a, b);
  int d = min(a, b);
  return c == 0 || d == 0 ? c : gcd(c % d, d);
}
long long lcm(long long a, long long b) {
  return a == 0 || b == 0 ? 0 : a * b / gcd(a, b);
}
long long fact(long long a) {
  long long b = 1;
  for (int i = 1; i <= a; i++) b *= i;
  return b;
}
long long power(long long x, long long n) {
  long long a = 1;
  for (int i = 0; i < n; i++) a *= x;
  return a;
}
int N, L, Q;
int main() {
  cin >> N;
  vector<long long> x(N);
  vector<int> y(N);
  for (int i = 0; i < N; i++) cin >> x[i];
  cin >> L;
  cin >> Q;
  for (int i = 0; i < N; i++)
    y[i] = (upper_bound(x.begin(), x.end(), x[i] + L) - 1) - x.begin();
  while (Q > 0) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int now = a;
    int ans = 0;
    while (now < b) {
      ans += 1;
      now = y[now];
    }
    cout << ans << endl;
    Q--;
  }
  return 0;
}
