#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],l,q;
int f[maxn][31];
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	cout.tie(0);		
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i];
    cin>>l;
    for (int i=1;i<=n;i++)
	{
        int idx=upper_bound(a+1,a+1+n,a[i]+l)-a-1;
        if(a[i]+l>=a[n]) f[i][0]=n;
        else f[i][0]=idx;
    }
    for (int j=1; j<=30; j++)
       for (int i=1;i<=n;i++)
            f[i][j]=f[f[i][j-1]][j-1];
    cin>>q;
    while(q--){
        long long u,v;
        cin>>u>>v;
        if(u>v) swap(u,v);
        long long dem;
        dem=0;
        for(int i=30;i>=0;i--)
          if(f[u][i]<v)
             {
             	dem+=(1<<i);
             	u=f[u][i];
			 }
        cout<<dem+1<<endl;
    }
}
