#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <sstream>
using namespace std;

#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
int l;
int q;
vector<int> x;

int main()
{
    cin >> n;
    x.resize(n,0);
    rep(i,0,n - 1)
    {
        cin >> x[i];
    }

    cin >> l >> q;

    stringstream result;

    rep(c,0,q - 1)
    {
        int a,b;
        cin >> a >> b;
        a--;b--;

        if(a < b)
        {
            int now = a;
            int cou = 0;
            while(now < b)
            {
                auto ite = upper_bound(x.begin(),x.end(),x[now] + l);
                ite--;
                int i = ite - x.begin();
                i = min(i,b);
                now = i;
                cou++;
            }
            result << cou << endl;
        }
        else
        {
            int now = a;
            int cou = 0;
            while(now > b)
            {
                auto ite = lower_bound(x.begin(),x.end(),x[now] - l);
                int i = ite-x.begin();
                i = max(i,b);
                now = i;
                cou++;
            }

            result << cou << endl;
        }
    }

    cout << result.str();
    return 0;
}