#include <bits/stdc++.h>
using namespace std;
long long N, L, Q;
long long A[200010];
vector<long long> adj[200010];
long long twok[200010][100], depth[200010];
bool vis[200010];
void twokdecomp(long long x, long long p) {
  vis[x] = 1;
  twok[x][0] = p;
  for (long long i = 1; i <= 18; i++) {
    if (twok[x][i - 1] == -1) break;
    twok[x][i] = twok[twok[x][i - 1]][i - 1];
  }
  for (auto i : adj[x]) {
    if (i != p) {
      depth[i] = depth[x] + 1;
      twokdecomp(i, x);
    }
  }
}
long long kth_parent(long long x, long long k) {
  for (long long i = 0; i <= 18; i++) {
    if (k & (1 << i)) {
      x = twok[x][i];
    }
    if (x == -1) break;
  }
  return x;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  cin >> N;
  for (long long i = 1; i <= long long(N); ++i) cin >> A[i];
  cin >> L >> Q;
  for (long long i = 1; i <= long long(N - 1); ++i) {
    long long idx = lower_bound(A + 1, A + N + 1, A[i] + L) - A;
    if (idx == N + 1 || A[idx] > A[i] + L) idx--;
    if (i == idx) continue;
    adj[i].push_back(idx);
    adj[idx].push_back(i);
  }
  memset(twok, -1, sizeof twok);
  twokdecomp(N, -1);
  for (long long i = 0; i <= long long(Q - 1); ++i) {
    long long a, b;
    cin >> a >> b;
    if (depth[a] < depth[b]) swap(a, b);
    long long l = 1, r = depth[a] + 10;
    while (l + 1 < r) {
      long long mid = (l + r) / 2;
      if (kth_parent(a, mid) == -1)
        r = mid;
      else if (kth_parent(a, mid) > b)
        r = mid;
      else
        l = mid;
    }
    cout << l << '\n';
  }
}
