#include <bits/stdc++.h>
using namespace std;
int N, L, Q;
int A[200010];
pair<long long, long long> adj[200010];
int 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) {
    if (A[i + 1] - A[i] > L) continue;
    int idx = lower_bound(A, A + N, A[i] + L) - A;
    if (idx == N || A[idx] > A[i] + L) idx--;
    adj[i] = pair<long long, long long>(idx, 1);
  }
  for (long long i = 0; i <= long long(Q - 1); ++i) {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a > b) swap(a, b);
    while (a < b) {
      ans += adj[a].second;
      a = adj[a].first;
    }
    cout << ans << '\n';
  }
}
