#include <bits/stdc++.h>
using namespace std;
long long n, q;
long long x[100005], l, y[100005][20];
vector<long long> vec;
signed main() {
  cin.tie(0), ios::sync_with_stdio(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> x[i];
    vec.push_back(x[i]);
  }
  vec.push_back(-1);
  sort(vec.begin(), vec.end());
  cin >> l;
  cin >> q;
  for (long long i = 1; i <= n; i++) {
    long long it =
        upper_bound(vec.begin(), vec.end(), x[i] + l) - vec.begin() - 1;
    y[i][0] = it;
  }
  for (long long i = 1; i <= 18; i++) {
    for (long long j = 1; j <= n; j++) y[j][i] = y[y[j][i - 1]][i - 1];
  }
  while (q--) {
    long long a, b, sum = 0;
    cin >> a >> b;
    if (a == b) {
      cout << sum << "\n";
      continue;
    }
    if (b < a) swap(a, b);
    for (long long i = 18; i >= 0; i--) {
      if (y[a][i] <= b) {
        a = y[a][i];
        sum += (1 << i);
      }
    }
    cout << sum << "\n";
  }
}
