#include <bits/stdc++.h>
using namespace std;
long long N, L, Q;
vector<long long> X;
vector<pair<long long, long long> > AB;
long long r[20][100010];
long long bin_search4(long long lb, long long ub, long long val) {
  lb--;
  ub--;
  while (ub - lb > 1) {
    long long mid = (lb + ub) / 2;
    if (X[mid] >= val) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  assert(false);
  if (X[ub] <= val) {
    return ub;
  }
  if (lb < 0) {
    assert(false);
    return -1;
  }
  if (X[lb] > val) {
    assert(false);
    return -1;
  }
  return lb;
}
long long doubling(long long a, long long b) {
  if (a == b) {
    return 0;
  }
  bool isReach = false;
  long long lb = 0, ub = 100010;
  while (ub - lb > 1) {
    long long mid = (lb + ub) / 2;
    long long k = a;
    for (int i = 20 - 1; i >= 0; --i) {
      if (((mid >> i) & 1) == 1) {
        k = r[i][k];
      }
    }
    if (b <= k) {
      isReach = true;
      ub = mid;
    } else {
      lb = mid;
    }
  }
  assert(isReach);
  return (isReach) ? ub : -1;
}
int main() {
  memset(r, 0, sizeof(r));
  cin >> N;
  for (long long i = 0; i < N; ++i) {
    long long x;
    cin >> x;
    X.push_back(x);
  }
  cin >> L >> Q;
  for (long long i = 0; i < Q; ++i) {
    long long a, b;
    cin >> a >> b;
    AB.push_back(make_pair(a - 1, b - 1));
  }
  for (long long i = 0; i < 20; ++i) {
    for (long long j = 0; j < N; ++j) {
      if (i == 0) {
        r[i][j] = bin_search4(j, N, X[j] + L);
      } else {
        r[i][j] = r[i - 1][r[i - 1][j]];
      }
    }
  }
  for (auto& q : AB) {
    printf("%lld\n", doubling(min(q.first, q.second), max(q.first, q.second)));
  }
  return 0;
}
