//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;

///---program start---///

int a[arr];
int st[arr][20];

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    int n;
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    int l;
    cin>>l;
    a[n]=a[n-1]+l;
    n++;
    int p=n-1;
    for (int i=n-1;i>=0;i--){
        while (a[p]-a[i]>l){
            p--;
        }
        st[i][0]=p;
    }
    for (int j=1;j<20;j++){
        for (int i=0;i<n;i++){
            st[i][j]=st[st[i][j-1]][j-1];
        }
    }
    int q;
    cin>>q;
    while (q--){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        if (a>b){
            swap(a,b);
        }
        int ans=0;
        for (int i=19;i>=0;i--){
            if (st[a][i]<=b){
                ans+=(1ll<<i);
                a=st[a][i];
            }
        }
        cout<<ans<<"\n";
    }
}
