#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9 + 7;
const double EPS = 1e-8;
template <typename T>
T chmax(T& a, const T& b) {
  return a = (a > b ? a : b);
}
template <typename T>
T chmin(T& a, const T& b) {
  return a = (a < b ? a : b);
}
namespace Doubling {
using NODE_TYPE = int;
using COST_TYPE = long long;
void preCalc(vector<vector<NODE_TYPE>>& d) {
  int n = d.size();
  int m = d[0].size();
  for (int j = (1); j < (int)(m); j++)
    for (int i = (0); i < (int)(n); i++) {
      d[i][j] = d[d[i][j - 1]][j - 1];
    }
}
NODE_TYPE getNode(NODE_TYPE u, COST_TYPE cost,
                  const vector<vector<NODE_TYPE>>& d) {
  assert(false);
  return -1;
}
COST_TYPE getCost(NODE_TYPE u, NODE_TYPE v,
                  const vector<vector<NODE_TYPE>>& d) {
  if (u >= v) assert(false);
  int n = d.size();
  int m = d[0].size();
  int cur = u;
  COST_TYPE ret = 0;
  while (cur != v) {
    if (d[cur][0] >= v) {
      ret += 1;
      break;
    }
    for (int j = (int)(m - 1); j >= (int)(0); j--)
      if (d[cur][j] <= v) {
        cur = d[cur][j];
        ret += COST_TYPE(1) << j;
        break;
      }
  }
  return ret;
}
};  // namespace Doubling
int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (int i = (0); i < (int)(N); i++) cin >> x[i];
  int L, Q;
  cin >> L >> Q;
  vector<int> a(Q), b(Q);
  for (int i = (0); i < (int)(Q); i++) cin >> a[i] >> b[i], --a[i], --b[i];
  vector<vector<int>> d(N, vector<int>(62, -1));
  for (int i = (0); i < (int)(N); i++) {
    d[i][0] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
  }
  Doubling::preCalc(d);
  for (int i = (0); i < (int)(Q); i++) {
    if (a[i] > b[i]) swap(a[i], b[i]);
    cout << Doubling::getCost(a[i], b[i], d) << endl;
  }
  return 0;
}
