#include <bits/stdc++.h>

using namespace std;
int hotel[200005];
int jump[200005][20];

/* Phan chuan bi LCA */
void pre_process()
{
    for(int i=1;i<=n;i++)
    {
        int p = upper_bound(hotel,hotel+n+2,hotel[i]+k) - hotel ;
        jump[i][0] = p-1;
    }

    for(int j=1;j<20;j++)
    {
        for(int i=1;i<=n;i++)
        {
            if(jump[i][j-1]!=-1)
                jump[i][j] = jump[jump[i][j-1]][j-1];
        }
    }
}

/* Phan tinh LCA */
int solve(int u,int v)
{
    if(u==v)
        return 0;
    int ans = 0;
    for(int i=17;i>=0;i--)
    {
        if(jump[u][i]<v)
        {
            u = jump[u][i];
            ans+=(1<<i);
        }
    }

    return ans+1;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n,k,q;
    cin>>n;

    hotel[n+1] = 2e9;
    memset(jump,-1,sizeof jump);

    for(int i=1;i<=n;i++)
    {
        cin>>hotel[i];
    }
    cin>>k;
    cin>>q;

    while(q--)
    {
        int u,v;
        cin>>u>>v;
        if(u>v)
            swap(u,v);

        cout<<solve(u,v)<<'\n';
    }

}
