#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <stdlib.h>
#include <assert.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, q, l, v[100000];
vector<vector<pair<int, int> > > dp, pre;
vector<vector<int> > b;
void calcBucket(vector<pair<int, int> > &dp, vector<pair<int, int> > &pre, vector<int> &v) {
	assert(!v.empty());
	int n = v.size();
	dp.resize(n);
	pre.resize(n);
	deque<pair<int, pair<int, int> > > q;
	for (int i = n - 1; i >= 0; --i) {
		while (!q.empty() && q.front().first - v[i] > l)
			q.pop_front();
		if (v[n - 1] - v[i] <= l)
			dp[i] = make_pair(1, -i);
		else {
			dp[i] = q.front().second;
			++dp[i].first;
		}
		while (!q.empty() && q.back().second >= dp[i])
			q.pop_back();
		q.push_back(make_pair(v[i], dp[i]));
	}
	pre[0] = dp[0];
	for (int i = 1; i < n; ++i)
		pre[i] = min(dp[i], pre[i - 1]);
}
int main()
{
	scanf("%d", &n);
	int last = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", v + i);
		int tmp = v[i];
		v[i] -= last;
		last = tmp;
		if (i)
			v[i] += v[i - 1];
	}
	scanf("%d", &l);
	int Z = sqrt(n)+3;
	b.resize((n + Z - 1) / Z);
	for (int i = 0; i < n; ++i)
		b[i / Z].push_back(v[i]);
	dp.resize(b.size());
	pre.resize(b.size());
	for (int i = 0; i < dp.size(); ++i) {
		calcBucket(dp[i], pre[i], b[i]);
	}
	vector<vector<int> > &B = b;
	scanf("%d", &q);
	vector<pair<int, int> > L, R, pL, pR;
	vector<int> vL, vR;
	int a, b;
	while (q--) {
		scanf("%d%d", &a, &b);
		--a; --b;
		if (a > b)
			swap(a, b);
		int res = 0;
		if (a == b);
		else if (a / Z + 1 >= b / Z) {
			vL.clear();
			for (int i = a; i <= b; ++i)
				vL.push_back(v[i]);
			calcBucket(L, pL, vL);
			res = L[0].first;
		}else {
			int x = a / Z*Z + Z;
			int y = b / Z*Z - 1;
			vL.clear();
			vR.clear();
			for (int i = a; i < x; ++i)
				vL.push_back(v[i]);
			for (int i = y + 1; i <= b; ++i)
				vR.push_back(v[i]);
			calcBucket(L, pL, vL);
			calcBucket(R, pR, vR);
			pair<int, int> last = L[0];
			int remLast = l - (vL[-last.second]-vL[0]);
			res = last.first;
			int prev = vL.back();
			for (int i = (x - 1) / Z + 1; i <= y / Z; ++i) {
				int at = upper_bound(B[i].begin(), B[i].end(), prev + remLast) - B[i].begin() - 1;
				if (at == -1) {
					++res;
					remLast = l;
					at = upper_bound(B[i].begin(), B[i].end(), prev + remLast) - B[i].begin() - 1;
				}
				else if (B[i].back() - prev <= remLast) {
					last = pre[i].back();
					remLast -= B[i][-last.second] - prev;
					prev = B[i][-last.second];
					continue;
				}
				res += pre[i][at].first;
				last = pre[i][at];
				remLast = l - (B[i][-last.second] - prev);
				prev = B[i][-last.second];
			}
			int at = upper_bound(vR.begin(), vR.end(), prev + remLast) - vR.begin() - 1;
			if (at == -1) {
				++res;
				remLast = l;
				at = upper_bound(vR.begin(), vR.end(), prev + remLast) - vR.begin() - 1;
			}
			if (vR.back() - prev > remLast) {
				res += pR[at].first;
			}
			++res;
		}
		printf("%d\n", res);
	}
	return 0;
}