#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100010
using namespace std;
int n,l,q;
int a[maxn],tp[maxn][25];
void init(){
	int to=1;
	for(int t=1;t<=n;++t){
		while(to<n&&a[t]+l>=a[to+1])to++;
		tp[t][0]=to;
	}
	for(int t=n;t>=1;--t){
		for(int i=1;i<=20;++i){
			tp[t][i]=tp[tp[t][i-1]][i-1];
		}
	}
}
bool check(int a,int b,int k){
	int now=0;
	for(int t=20;t>=0;--t){
		if(now+(1<<t)<=k){
			now+=1<<t;
			a=tp[a][t];
		}
	}
	return a>=b;
}
int getans(int a,int b){
	int l=1,r=n,ans=n;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(a,b,mid)){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	return ans;
}
int main(){
	scanf("%d",&n);
	for(int t=1;t<=n;++t)scanf("%d",&a[t]);
	scanf("%d%d",&l,&q);
	init();
	for(int t=1;t<=q;++t){
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>b)swap(a,b);
		printf("%d\n",getans(a,b));
	}
}
#include <iostream>
#include <vector>

using namespace std;

void abc_150a();

void abc_151a();

void abc_152a();

void abc_154a();

void abc_156a();

int main()
{
  //abc_150a();
  //abc_151a();
  //abc_152a();
  //abc_154a();
  abc_156a();

}

void abc_150a()
{
  int K, X;
  cin >> K >> X;

  if (500 * K >= X) cout << "Yes\n";
  else cout << "No\n";
}

void abc_151a()
{
  char C;
  cin >> C;

  cout << (char)((int)C + 1) << "\n";
}

void abc_152a()
{
  int N, M;
  cin >> N >> M;
  if (N == M) cout << "Yes\n";
  else cout << "No\n";
}

void abc_154a()
{
  string S, T;
  cin >> S >> T;
  int a, b;
  cin >> a >> b;
  string U;
  cin >> U;

  if (S == U) cout << a - 1 << " " << b << "\n";
  else cout << a << " " << b - 1 << "\n";

}


void abc_156a()
{
  int N, R;
  cin >> N >> R;

  if (N >= 10) cout << R << "\n";
  else cout << R + 100 * (10 - N) << "\n";
}