#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LLINF = 1e18;
static const double pi = 3.141592653589793;
const int MAX_N = 100009;
const int MAX_LOG = 20;
int G[MAX_N][MAX_LOG];
int N, L, Q;
vector<long long> nums;
void doubling() {
  for (int p = 1; p <= MAX_LOG - 1; p++) {
    for (int i = 0; i < N; i++) {
      G[i][p] = G[G[i][p - 1]][p - 1];
    }
  }
}
int calc(int a, int b, int d) {
  int res = 0;
  while (G[a][res + 1] <= b) res++;
  d += (1 << res);
  if (G[a][res] >= b)
    return d;
  else
    return calc(G[a][res], b, d);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  nums.resize(N);
  for (int i = 0; i < N; i++) cin >> nums[i];
  cin >> L;
  for (int i = 0; i < N; i++) {
    long long d = nums[i] + L;
    int idx = upper_bound(nums.begin(), nums.end(), d) - nums.begin() - 1;
    G[i][0] = idx;
  }
  doubling();
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    cout << calc(a, b, 0) << endl;
    ;
  }
}
