/*               ______  ______
 \      / |\   |    |    |       |    |  |   |
  \    /  | \  |    |    |____   |____|  |___|
   \  /   |  \ |    |        |   |    |  |   |
    \/    |   \|    |   _____|   |    |  |   |

  -----------IIT Indore----------*/
#include<bits/stdc++.h>
#define rep(i,start,lim) for(long long i=start;i<lim;i++)
#define repd(i,start,lim) for(long long i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define sz(a) lld((a).size())
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define tr(it,c) for(__typeof(c.begin()) it = c.begin(); it!=c.end(); ++it)
#define br printf("\n")
#define checkbit(n,b) ((n>>b)&1)
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#else
#define trace1(x)                printf("")
#define trace2(x, y)             printf("")
#define trace3(x, y, z)          printf("")
#define trace4(a, b, c, d)       printf("")
#define trace5(a, b, c, d, e)    printf("")
#define trace6(a, b, c, d, e, f) printf("")
#endif
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
inline lld lcm(lld a,lld b){ return (a/__gcd(a, b))*b; }
template<typename T1, typename T2> inline pair<T1, T2> operator+(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first + p2.first, p1.second + p2.second); }
template<typename T1, typename T2> inline pair<T1, T2> operator-(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first - p2.first, p1.second - p2.second); }
#define DA(a,n) cout<<#a<<"=["; printarray(a,n); cout<<"]\n"
#define DAR(a,n,s) cout<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cout<<"]\n"
template<typename T, typename T2>void printarray(T a[], T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; }
#define N 100005
#define LOGN 20
lld tmp,q,x,y,ans,curr,flag,dp[N][LOGN],n,l,a[N];
void pre()
{
	memset(dp,-1,sizeof dp);
	rep(i,0,n) 
	{
		tmp=lower_bound(a,a+n,a[i]+l)-a;
		if(a[tmp]!=a[i]+l) dp[i][0]=(tmp-1);
		else dp[i][0]=tmp;
	}
	rep(j,1,LOGN) rep(i,0,n) dp[i][j]=dp[dp[i][j-1]][j-1];
}
int main()
{
	cin>>n;
	rep(i,0,n) scan(a[i]);
	scan(l),scan(q);
	pre();
	//rep(i,0,n) rep(j,0,LOGN) cout<<dp[i][j]<<" \n"[j==LOGN-1];
	while(q--)
	{
		scan(x),scan(y);
		--x,--y;
		if(x>y) swap(x,y); 
		ans=0,curr=x,flag=0;
		while(1)
		{
			//cout<<curr<<endl;
			repd(i,LOGN-1,0)
			{
				//cout<<i<<" "<<dp[curr][i]<<endl;
				if(dp[curr][i]==y) 
				{
					flag=1;
					ans+=(1<<i);
					print(ans),br;
					break;
				}
				else if(dp[curr][i]<y)
				{
					curr=dp[curr][i];
					ans+=(1<<i);
					break;
				}
			}
			//cout<<"Nikla:"<<curr<<endl;
			if(flag) break;
		}
	}
	return 0;
}
/*
9
1 3 6 13 15 18 19 29 31
10
4
1 8
7 3
6 7
8 5*/

