//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=100005;

int cycleNo[N];
vector<int>adj[N];
bool vis[N];
int nxt[N];
int n;

void dfs(int u,int p){
	if(vis[u]){
		return;
	}
	if(u==n-1){
		return;
	}
	vis[u]=true;
	cycleNo[u]=p;
	adj[p].pb(u);
	dfs(nxt[u],p);	
}

void solve(){
	cin>>n;
	vi a(n);
	cin>>a;
	int L;
	cin>>L;
	int q;
	cin>>q;
	vector<pair<int,int>>queries;
	for(int i=0;i<q;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		queries.pb({x,y});
	}
	vector<int>ans(q,-1);
	vector<int>prf(n);
	for(int i=0;i<n-1;i++){
		prf[i+1]=a[i+1]-a[i];
		prf[i+1]+=prf[i];
	}
	for(int i=n-2;i>=0;i--){
		int l=i+1,r=n-1;
		int con=prf[i],val=i+1;
		while(l<=r){
			int mid=(l+r)/2;
			if((prf[mid]-con)<=L){
				l=mid+1;
				val=max(val,mid);
			}
			else{
				r=mid-1;
			}
		}
		nxt[i]=val;
	}
	for(int i=0;i<n-1;i++){
		if(vis[i]==false){
			dfs(i,i);
			sort(all(adj[i]));
		}
	}
	for(int i=0;i<q;i++){
		int x,y;
		tie(x,y)=queries[i];
		if(x<y){
			auto it=lower_bound(all(adj[cycleNo[x]]),y)-adj[cycleNo[x]].begin();
			auto it2=lower_bound(all(adj[cycleNo[x]]),x)-adj[cycleNo[x]].begin();
			ans[i]=it-it2;
		}
	}
	for(int i=0;i<n;i++){
		adj[i].clear();
		nxt[i]=0;
		vis[i]=false;
		prf[i]=0;
	}
	reverse(all(a));
	for(int i=0;i<n-1;i++){
		prf[i+1]=abs(a[i+1]-a[i]);
		prf[i+1]+=prf[i];
	}
	for(int i=n-2;i>=0;i--){
		int l=i+1,r=n-1;
		int con=prf[i],val=i+1;
		while(l<=r){
			int mid=(l+r)/2;
			if((prf[mid]-con)<=L){
				l=mid+1;
				val=max(val,mid);
			}
			else{
				r=mid-1;
			}
		}
		nxt[i]=val;
	}
	for(int i=0;i<n-1;i++){
		if(vis[i]==false){
			dfs(i,i);
			sort(all(adj[i]));
		}
	}
	for(int i=0;i<q;i++){
		int x,y;
		tie(x,y)=queries[i];
		x=n-x-1;
		y=n-y-1;
		if(x<y){
			auto it=lower_bound(all(adj[cycleNo[x]]),y)-adj[cycleNo[x]].begin();
			auto it2=lower_bound(all(adj[cycleNo[x]]),x)-adj[cycleNo[x]].begin();
			ans[i]=it-it2;
		}
	}
	for(auto i:ans){
		cout<<i<<'\n';
	}
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    //~cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}

