#include <iostream>
using namespace std;

int main(){
	int numOfHotels, mostDis, Q, max, now, now_max = 0, t = 0, d;
	cin >> numOfHotels;
	int hotels[numOfHotels+1] = {};
	for(int i = 1; i <= numOfHotels; i++){
		cin >> hotels[i];
	}
	cin >> mostDis;
	cin >> Q;
	int travel[Q*2] = {}, results[Q] = {};
	for(int i = 0; i < Q*2; i++){
		cin >> travel[i];
	}
	
	for(int i = 0; i < Q*2; i+=2){
		if(travel[i+1] < travel[i]){
			travel[i+1] = travel[i] + travel[i+1];
			travel[i] = travel[i+1] - travel[i];
			travel[i+1] = travel[i+1] - travel[i];
		}
		for(int j = travel[i+1]; j >= travel[i]; ){
			for(d = j-1; d >= travel[i]; d--){
				if(hotels[j] - hotels[d] <= mostDis){
					if(now_max < hotels[j] - hotels[d]){
						now_max = hotels[j] - hotels[d];
						now = d;
					}
				}
			}
			now_max = 0;
			j = now;
			results[t]++;
			if(j == travel[i]){
				break;
			}
		}
		t++;
	}
	for(int i = 0; i < Q; i++){
		cout << results[i] << endl;
	}
	
	return 0;
}