#include <bits/stdc++.h>
using namespace std;
const long long int INF = 99999999999999;
const long long int MOD = 1000000007;
long long int a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
vector<long long int> A;
class LCA {
 public:
  long long int LOG_N = floor(log2(n)) + 1;
  vector<vector<long long int> > NEXT;
  vector<long long int> DEPTH;
  void init() {
    DEPTH = vector<long long int>(n, -1);
    NEXT = vector<vector<long long int> >(LOG_N + 2, vector<long long int>(n));
    for (long long int i = 0; i < n; ++i) {
      NEXT[0][i] = upper_bound(A.begin(), A.end(), A[i] + l) - A.begin() - 1;
      cout << NEXT[0][i] << " ";
    }
    for (long long int k = 0; k < LOG_N; k++) {
      for (long long int i = 0; i < n; i++) {
        if (NEXT[k][i] == n) {
          NEXT[k + 1][i] = n;
        } else {
          NEXT[k + 1][i] = NEXT[k][NEXT[k][i]];
        }
      }
    }
  }
  long long int vertex(long long int p, long long int Q) {
    for (long long int k = LOG_N - 1; k >= 0; --k) {
      if (p == -1) {
        break;
      }
      if ((Q >> k) & 1) {
        p = NEXT[k][p];
      }
    }
    return p;
  }
  long long int depth(long long int x) {
    if (DEPTH[x] == -1) {
      long long int ok = n, ng = -1;
      while (ok - ng > 1) {
        if (this->vertex(x, (ok + ng) / 2) > -1)
          ng = (ok + ng) / 2;
        else
          ok = (ok + ng) / 2;
      }
      DEPTH[x] = ok;
      return ok;
    } else
      return DEPTH[x];
  }
  long long int kyoutuu(long long int x, long long int y) {
    long long int a = this->depth(x);
    long long int b = this->depth(y);
    if (a > b) {
      swap(x, y);
      swap(a, b);
    }
    long long int t = this->vertex(y, b - a);
    long long int ok = n, ng = -1;
    while (ok - ng > 1) {
      long long int mid = (ok + ng) / 2;
      if (this->vertex(x, mid) == this->vertex(t, mid))
        ok = (ok + ng) / 2;
      else
        ng = (ok + ng) / 2;
    }
    return b - a + ok * 2 + 1;
  }
  long long int saitei(long long int x, long long int y) {
    if (x > y) swap(x, y);
    long long int ok = n, ng = -1;
    while (ok - ng > 1) {
      long long int mid = (ok + ng) / 2;
      if (this->vertex(x, mid) >= y)
        ok = (ok + ng) / 2;
      else
        ng = (ok + ng) / 2;
    }
    return ok;
  }
};
void input() {
  cin >> n;
  for (long long int i = 0; i < long long int(n); i++) {
    long long int x;
    cin >> x;
    A.push_back(x);
  };
  A.push_back(INF);
  n++;
  cin >> l;
  cin >> q;
  LCA LCA1;
  LCA1.init();
  while (q--) {
    cin >> x >> y;
    cout << LCA1.saitei(x - 1, y - 1) << endl;
  }
}
void solve() {}
int main() {
  input();
  solve();
}
