/*
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
      //////////////////////////////////////////
	 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

 Work hard in silence , let success make a noise!
	- The harder I work THE GREATER MY SUCCCESS -
	'''''''''''''''''''''''''''''''''''''''''
	|	XXX IOI 2018 - Tokyo Japan      |
	'''''''''''''''''''''''''''''''''''''''''
	 It's hard to beat a person who never gives up,
		 and this person can be you!

	  ///////////////////////////////////
       \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
||||||||||||||||||||||||||||||||||||||||||||||||||||||||


*/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define in freopen(".in", "r", stdin)
#define out freopen(".out", "w", stdout)
#define int long long

using namespace std;

const long long INF = (long long)1e17 + 7;
const long long Ln = (long long)1e12 + 7;
const int N = (int)1e6 + 7;
const int sz = (int)1e5 + 7;
const double PI = 3.141592;
const int MX = (int)1e9 + 7;

inline int max(int a, int b)
{
 	if (a > b)return a;

	return b;
}
inline int min(int a, int b)
{
 	if (a < b)return a;

	return b;
}

vector<int>vec;
vector<int>a;
bool u[100007], us[100007];
int pref[100007];

main()
{
    int n, k, b, j = 1;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> b;
        vec.pb(b);
    }
    cin >> k;
    int cur = vec[0];

    for (int i = 1; i < n; i++)
    {
        if (vec[i] - cur > k)
        {
            a.pb(i - 1);
            cur = vec[i - 1];
        }
    }
    a.pb(n - 1);


    for (int i = 0; i < a.size(); i++)
        u[a[i]] = 1;

    pref[0] = u[0];
    for (int i = 1; i < n; i++)
        pref[i] += (pref[i - 1] + u[i]);

    for (int i = 0; i < n - 1; i++)
    {
        if (vec[a[pref[i]] + 1] - vec[i] <= k && (i != a[pref[i]]))
            us[i] = 1;
    }

    int q;
    cin >> q;

    while (q--)
    {
        int l, r;
        cin >> l >> r;
        if (l > r)swap(l, r);
        r--;
        l--;
        cout << abs(pref[r] - pref[l] - (us[l] > us[r]) ? us[l] : us[r]) + ((pref[l] != pref[r]) ? abs(pref[l] - pref[r]) : 0) << endl;
    }
}


