#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int infi = 1147483600;
const long long infl = 1e18 + 5;
const char ENDL = '\n';
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  vector<long long> x(n);
  for (long long i = 0; i < (long long)n; i++) cin >> x[i];
  vector<long long> path(n);
  long long l, q;
  cin >> l >> q;
  for (long long i = 0; i < (long long)n - 1; i++) {
    long long idx = upper_bound((x).begin(), (x).end(), x[i] + l) - x.begin();
    idx--;
    path[i] = idx;
  }
  path[n - 1] = -1;
  vector<pair<long long, long long> > query;
  map<pair<long long, long long>, int> que_idx;
  for (long long i = 0; i < (long long)q; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a < b) swap(a, b);
    query.emplace_back(make_pair(a, b));
    que_idx[make_pair(a, b)] = i;
  }
  vector<long long> ans(q);
  vector<long long> goal(n, -1);
  vector<long long> dist(n, -1);
  goal[n - 1] = n - 1;
  dist[n - 1] = 0;
  sort((query).begin(), (query).end());
  for (long long i = 0; i < (long long)q; i++) {
    int a = query[i].second, b = query[i].first;
    int now = a, cnt = 0;
    vector<pair<long long, long long> > visited;
    while (now < b) {
      if (goal[now] != -1) {
        visited.emplace_back(make_pair(now, dist[now]));
        cnt += dist[now];
        now = goal[now];
      } else {
        visited.emplace_back(make_pair(now, 1));
        cnt++;
        now = path[now];
      }
    }
    ans[que_idx[query[i]]] = cnt;
    for (long long j = 0; j < (long long)visited.size(); j++) {
      goal[visited[j].first] = now;
      dist[visited[j].first] = cnt;
      cnt -= visited[j].second;
    }
  }
  for (long long i = 0; i < (long long)q; i++) cout << ans[i] << ENDL;
}
