#include<bits/stdc++.h>
using namespace std;

long long nexta[18][100001];

long long arr(long long from, long long days){
    long long shisu=0;
    while(days>0){
        if(days%2==1){
            from=nexta[shisu][from];
        }
        days/=2;
        shisu++;
    }
    return from;
}

int main(){
    //input
    long long N;
    cin >> N;
    long long x[N+1];
    long long i,j;
    for(i=1; i<=N; i++){
        cin >> x[i]; 
    }
    long long L;
    cin >> L;
    long long Q;
    cin >> Q;
    long long a[Q+1], b[Q+1];
    for(i=1; i<=Q; i++){
        cin >> a[i] >> b[i];
        if(a[i]>b[i]) swap(a[i],b[i]);
    }

    //calc
    for(i=1; i<=N; i++){
        j=lower_bound(x+1,x+N+1,x[i]+L)-x;
        if(j>N){
            nexta[0][i]=N;
            continue;
        }
        if(x[i]+L<x[j]){
            j--;
        }
        nexta[0][i]=j;
    }
    for(i=1; i<18; i++){
        for(j=1; j<=N; j++){
            nexta[i][j]=nexta[i-1][nexta[i-1][j]];
        }
    }
    long long ans[Q+1];
    long long lef, rig, mid;
    long long arrarr, arrarrarr;
    for(i=1; i<=Q; i++){
        lef=0;
        rig=N;
        while(lef<rig-1){
            mid=(lef+rig)/2;
            arrarr=arr(a[i],mid-1);
            if(arrarr>=b[i]){
                rig=mid;
            }else{
                lef=mid;
            }
        }
        ans[i]=lef;
    }


    //output
    for(i=1; i<=Q; i++){
        cout << ans[i] << endl;
    }
    system("pause");
    return 0;
}
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1050;
#define singleCase
// #define multipleCase
int n,m,a,b;
string grid[N];

void work() {
   cin >> n >> m >> a >> b;
   string s = "";
   for (int i = 1 ; i <= a ; i++) {
      s += "1";
   }
   for (int i = 1 ; i <= m - a ; i++) {
      s += "0";
   }
   for (int i = 1 ; i <= b ; i++) {
      grid[i] = s;
   }
   for (int i = 0 ; i < m ; i++) {
      s[i] = s[i] == '0' ? '1' : '0';
   }
   for (int i = b + 1 ; i <= n ; i++) {
      grid[i] = s;
   }
   for (int i = 1 ; i <= n ; i++) {
      for (int j = 0 ; j < m ; j++) {
         printf("%c" , grid[i][j]);
      } puts("");
   }
   return;
}

int main() {
   #ifdef multipleCase
      int nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(int &x) {
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}
