#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

#define MOD 1000000007

struct Q {
	int b_id;
	int steps;
	int q_id;

	Q(int b_id, int q_id) : b_id(b_id), q_id(q_id), steps(0) {}

	bool operator<(const Q& other) const
	{
		return std::tie(b_id, q_id) < std::tie(other.b_id, other.q_id);
	}
};

int ofs[1000000];
int ans[1000000];
vector<set<Q>> qs;

void merge_into(int from, int to)
{
	if (qs[from].size() > qs[to].size())
	{
		swap(qs[from], qs[to]);
		swap(ofs[from], ofs[to]);
	}
	for (auto x : qs[from])
	{
		x.steps += ofs[from] - ofs[to];
		qs[to].insert(x);
	}
	qs[from].clear();
}

int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin >> n;

	vector<int> x(n);
	for (int i = 0; i < n; i++)
		cin >> x[i];

	qs.resize(n);

	int L;
	cin >> L;

	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int a, b;
		cin >> a >> b;
		a--, b--;

		if (a > b)
			swap(a, b);
		qs[a].insert(Q(b, i));
	}

	for (int i = 0; i < n; i++)
	{
		while (qs[i].size() > 0 && qs[i].begin()->b_id <= i)
		{
			auto f = *qs[i].begin();
			qs[i].erase(qs[i].begin());
			ans[f.q_id] = f.steps + ofs[i];
		}
		ofs[i]++;
		int to = lower_bound(x.begin(), x.end(), x[i] + L + 1) - x.begin() - 1;
		merge_into(i, to);
	}

	for (int i = 0; i < q; i++)
		cout << ans[i] << "\n";

	return 0;
}

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

/***********debug tools***********/
template<class T> inline ostream& operator<<(ostream& os,vector<T> arr) {os << "["; for(int i = 0; i < (int)arr.size(); i++)os << arr[i] << (i == (int)arr.size() - 1 ? "]" : ",");os << endl;return os;}
template<typename A, typename B> ostream& operator<<(ostream& os, const pair<A,B>& p){os << "{" << p.first << "," << p.second << "}";return os; }
#define prvec(v) cerr<<#v<<": [";for(int __i = 0;__i < (int)(v).size(); __i++)cerr<<((v)[__i])<<(__i+1==(int)(v).size()?"]\n":",");
#define print(x) cerr<<#x<<": "<<(x)<<endl
/*********************************/

const int D = 30;
const int MAX_N = 100000;

int n, l;
vector<int> x;
vector<vector<int>> tor, tol;



void ftor() {
    for(int i = 0; i < n; i++) {

        int L = i + 1, R = n; //ooooxxx
        while(R - L > 1) {
            int mid = (L + R) / 2;
            (x[mid] - x[i] <= l ? L : R) = mid;
        }
        tor[0][i] = L;
    }
    tor[0][n - 1] = n - 1;

    for(int i = 0; i < D - 1; i++) {
        for(int j = 0; j < n; j++) {
            tor[i + 1][j] = tor[i][tor[i][j]];
        }
    }

}

void ftol() {
    for(int i = 1; i < n; i++) {
        int L = -1, R = i - 1;//xxxxxoooo
        while(R - L > 1) {
            int mid = (L + R) / 2;
            (x[i] - x[mid] <= l ? R : L) = mid;
        }
        tol[0][i] = R;
    }
    tol[0][0] = 0;
    for(int i = 0; i < D - 1; i++) {
        for(int j = 0; j < n; j++) {
            tol[i + 1][j] = tol[i][tol[i][j]];
        }
    }

}


int main()
{
    cin >> n;
    x.resize(n), tor.resize(D, vector<int>(n));
    tol = tor;
    for(int i = 0; i < n; i++)cin >> x[i];
    cin >> l;
    ftor();
    ftol();

    int Q; cin >> Q;
    while(Q--) {
        int a, b;
        cin >> a >> b;
        a--,b--;
        if(a > b) {

            int l = 0, r = 2 * n;//xxxxxxoooo
            while(r - l > 1) {
                int mid = (l + r) / 2;
                int pos = a;
                for(int i = 0; i < D; i++) {
                    if(mid & (1<<i))pos = tol[i][pos];
                }
                (pos <= b ? r : l) = mid;
            }
            cout << r << endl;      
            

        } else {
            int l = 0, r = 2 * n;//xxxxxxoooo
            while(r - l > 1) {
                int mid = (l + r) / 2;
                int pos = a;
                for(int i = 0; i < D; i++) {
                    if(mid & (1<<i))pos = tor[i][pos];
                }
                (pos >= b ? r : l) = mid;
            }
            cout << r << endl;
        }

    }

}
