#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
        #include<functional>
      #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------
/*        
        int par[100100],ranks[100100],kosuu[100100];     

void shoki(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		ranks[i]=0;
		kosuu[i]=1;
	}
}

int root(int x){
	return par[x]==x ? x : par[x]=root(par[x]);
}

bool same(int x,int y){
return root(x)==root(y);
}

void unite(int x,int y){
 x=root(x);
 y=root(y);
 if(x==y) return;
	if(ranks[x]<ranks[y]){
		par[x]=y;
		kosuu[y]+=kosuu[x];
	}
 else {
	par[y]=x;
 	kosuu[x]+=kosuu[y];
	if(ranks[x]==ranks[y]) ranks[x]=ranks[x]+1;
 }
}

int kazu(int x){
	return kosuu[root(x)];
}
*/
/*
ll frac[100010];
ll inv[100010];
ll mod;
ll saikif(ll a,int n){
	if (n==0) return 1;
  if(n==1) return a%mod;
  else if(n%2==0){
    ll q=saikif(a,n/2);
    return (q*q)%mod;
  }
  else return (a*saikif(a,n-1))%mod;
}

void gyakugen(){
  frac[0]=1;
  for(int i=1;i<=100000;i++) frac[i]=(frac[i-1]*i)%mod;
  for(int i=0;i<=100000;i++) inv[i]=saikif(frac[i],mod-2);
}


int rui[1000][1000];
int dp[500][500]={0};
*/

/*

vector<int> i2g;         
vector<int> g2i[200020]; 

void init(int n) {
  i2g.resize(n);
//  g2i.resize(n);
  for (int i = 0; i <= n; ++i) {
  
    i2g[i] = i;
  	vector<int> ve;
  	g2i[i].push_back(i);
  //	g2i.push_back(ve);
   // g2i[i].assign(1, i);
  }
	
	return;
}
bool same(int ia, int ib) {
  return i2g[ia] == i2g[ib];
}
void unite(int ia, int ib) {
	
	if(same(ia,ib)) return;
  if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) {
    swap(ia, ib);
  }


  int ga = i2g[ia], gb = i2g[ib];
  for (int j=0 ; j<g2i[gb].size();j++) i2g[g2i[gb][j]] = ga;
  g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
  g2i[gb].clear();
	/*
	for(int i=1;i<=5;i++){
		for(int j=0;j<g2i[i2g[i]].size();j++) cout<<g2i[i2g[i]][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
	
	return;
}
*/
//int dp[60][6000]={0};

int dp[100006][60];

vector<int> x;
signed main(){
	x.push_back(0);
int n,l,q;
cin>>n;
//	if(n>1002) return 0;
	for(int i=1;i<=n;i++){
		int y;
		cin>>y;
		x.push_back(y);
	}
	cin>>l>>q;
	x[n+1]=2000000013;
	
	for(int i=1;i<=n;i++){
		dp[i][0]=upper_bound(x.begin(),x.end(),x[i]+l)-x.begin();
		dp[i][0]--;
	//	cout<<dp[i][0]<<endl;
	}
	
	for(int j=1;j<=55;j++){
		for(int i=1;i<=n;i++){
			dp[i][j]= dp[dp[i][j-1]][j-1];
		//	cout<<dp[i][j]<<" ";
			
		}
	//	cout<<endl;
	}
	
//	cout<<"---"<<endl;
	for(int qq=0;qq<q;qq++){
		int a,b;
		cin>>a>>b;
		if(a>b) swap(a,b);
		int ans=0;
		
		int i=50;
		while(i>=0){
			if(i==0){
				if(a>=b) break;
				else {
					a=dp[a][i];
					ans ++;
				}
			}
			
			
			else if( dp[a][i]>=b){
				i--;
		//		continue;
			}
			
			else{
				a=dp[a][i];
				ans += (1<<i);
			}
	//		cout<<ans<<" "<<a<<" "<<i<<endl;
		}
	 cout<<ans<<endl;
	
//	cout<<endl;
	}
	
	
	
	

	
	
	return 0;
        }
        
//printf("%.10f\n",ans);


Measured memory_bytes: 48628