#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;
int n, L, q;
int a[N];
deque<pair<int, int> > dq;
deque<int> v[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> L >> q;
  for (int i = n; i >= 1; i--) {
    int pos = upper_bound(dq.begin(), dq.end(), make_pair(a[i] + L, n + 1)) -
              dq.begin() - 1;
    if (pos != -1) v[i] = v[dq[pos].second];
    v[i].push_front(i);
    dq.push_front(make_pair(a[i], i));
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    if (l > r) swap(l, r);
    int pos = lower_bound(v[l].begin(), v[l].end(), r) - v[l].begin() - 1;
    if (v[l][pos] != r)
      cout << pos + 1 << endl;
    else
      cout << pos << endl;
  }
}
