#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 100005;
int n,l,q;
int nxt[N][20];

int main(){
	fast_io();
	cin >> n;	
	vector<int> v(n);
	cu(i,0,n)cin >> v[i];
	cin >> l >> q;
	cu(i,0,n){
		int ind = upper_bound(v.begin(),v.end(), v[i] + l) - v.begin();
		nxt[i][0] = ind - 1;
	}
	nxt[n-1][0] = n;
	cu(i,0,20)nxt[n][i] = n;
	cu(j,1,20){
		cu(i,0,n){
			nxt[i][j] = nxt[nxt[i][j-1]][j-1];
		}
	}
	cu(i,0,q){
		int cur = 0,dest;
		cin >> cur >> dest;
		if(cur > dest)swap(cur,dest);
		int ans = 0;
		--cur;--dest;
		while(cur < dest){
			int len = 0;
			while(len < 19 && nxt[cur][len + 1] <= dest){
				whatis(nxt[cur][len]);
				++len;
			}
			ans += (1 << len);
			cur = nxt[cur][len];
		}
		cout << ans << '\n';
	}
}
