using System;


class A {
    int N;
    int maxN = 100005;
    int K;
    long L;
    int Q;
    long[] x;
    int[,] l;
    public A(){
        x = new long[maxN];
        l = new int[20,maxN];
    }
    public int calc(int a, int b){
        for(int i=0;i<K;i++){
            int h = (int)Math.Pow(2,i);
            if(l[i,a] == b){
                return h;
            } else if(l[i,a] > b){
                if(i<2){
                    return h;
                } else {
                    int d = h/2;
                    return d + calc(l[i-1,a],b);
                }
            }
        }
        return -1;
    }
    public void run(){
        N = int.Parse(Console.ReadLine());
        string[] ss = Console.ReadLine().Split(' '); 
        for(int i=0;i<N;i++){
            x[i] = long.Parse(ss[i]);
        }
        L = long.Parse(Console.ReadLine());
        Q = int.Parse(Console.ReadLine());
        
        K = (int)Math.Log(N,2)+4;
        
        int p = 1;
        for(int i=0;i<N;i++){
            while(p<N && x[p]-x[i] <= L) p++;
            p--;
            l[0,i] =  p;
        }
        
        for(int k=1;k<K;k++){
            for(int i=0;i<N;i++){
                l[k,i] = l[k-1,l[k-1,i]];
            }
        }
        
        
        for(int _=0;_<Q;_++){
            ss = Console.ReadLine().Split(' '); 
            int a = int.Parse(ss[0])-1;
            int b = int.Parse(ss[1])-1;
            if(a>b){
                int tmp = a;
                a = b;
                b = tmp;
            }
            
            Console.WriteLine(calc(a,b));
        }
        
    }
}


class Program {
    static void Main(string[] args){
        A a = new A();
        a.run();    
    }
}