#include<bits/stdc++.h>

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
typedef struct aaaaa{
  int x,y,t;
}Grid;
using namespace std;
int main(){
  int n;cin>>n;
  vector<ll>ori(n);
  vector<vector<ll> >vvll(n);
  map<ll,int>mli;
  bool used[n+10]={};
  for(int i=0;i<n;i++)
    cin>>ori[i];
  ll L;cin>>L;
  int q;cin>>q;
  ori.pb(llINF);
  int cnt=0;
  for(int i=0;i<n;i++){
    if(used[i])continue;
    vvll[cnt].pb(ori[i]);
    ll hoge=ori[i];
    mli[i]=cnt;
    while(hoge!=llINF){
      auto po = upper_bound(ALL(ori),hoge+L);
      if(*po == llINF){
	if(ori[ori.size()-2]-hoge<=L){
	  mli[ori.size()-2]=cnt;
	  used[ori.size()-2]=true;
	  vvll[cnt].pb(ori[ori.size()-2]);
	  break;
	}
      }
      int num=(po-ori.begin())-1;
      if(num<0)num=0;
      used[num]=true;
      hoge = ori[num];
      mli[num]=cnt;
      vvll[cnt].pb(ori[num]);
    }
    cnt++;
  }
  /* for(int i=0;i<vvll.size();i++){
    for(int j=0;j<vvll[i].size();j++)
      cout<<vvll[i][j]<<" ";
    cout<<endl;
    }*/

  for(int i=0;i<q;i++){
    int le,ri;scanf("%d %d",&le,&ri);
    //cout<<mli[min(le,ri)-1]<<endl;
    //cout<<ori[min(le,ri)-1]<<" "<<ori[max(le,ri)-1]<<endl;
    ll num=min(le,ri)-1;
    auto a = lower_bound(ALL(vvll[num]),ori[min(le,ri)-1]);
    auto b = lower_bound(ALL(vvll[num]),ori[max(le,ri)-1]);
    printf("%d\n",(b-a));
  }
  return 0;
}
