#include <bits/stdc++.h>
const long long LOG = 20;
const long long MAX_N = 100005;
const long long INF = 1e8;
using namespace std;
long long t[LOG][MAX_N];
long long lower_bound(long long t, vector<long long> x, long long n) {
  long long right = n, left = 0;
  for (long long i = 0; i < (LOG); i++) {
    long long mid = (right + left) / 2;
    if (x[mid] <= t)
      left = mid;
    else
      right = mid;
  }
  return left;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> x(n);
  for (long long i = 0; i < (n); i++) cin >> x[i];
  for (long long i = 0; i < (LOG); i++)
    for (long long j = 0; j < (MAX_N); j++) t[i][j] = INF;
  long long l, q;
  cin >> l >> q;
  for (long long i = 0; i < (n); i++) {
    t[0][i] = lower_bound(x[i] + l, x, n);
  }
  for (long long i = 0; i < (LOG - 1); i++) {
    for (long long j = 0; j < (MAX_N); j++) {
      if (t[i][j] == INF) continue;
      t[i + 1][j] = t[i][t[i][j]];
    }
  }
  for (long long i = 0; i < (q); i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    long long ans = 0;
    for (long long i = LOG - 1; i >= 0; i--) {
      if (t[i][a] < b) {
        a = t[i][a];
        ans += (1LL << i);
      }
    }
    cout << ans + 1 << endl;
  }
}
