import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
        return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
        return readInts()[0];
}
auto readLongs() {
        return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
        return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;


void main(){
    auto N = readLong();
    auto x = readLongs();
    auto L = readLong();
    auto list = new long[][](N, 50);
    foreach(i; iota(N)) {
        list[i][0] = x.length - x.assumeSorted.upperBound(x[i] + L).length - 1;
    }
    foreach(j; iota(1, 50)) {
        foreach(i; iota(N)) {
            list[i][j] = list[list[i][j-1]][j-1];
        }
    }

    long calc(long a, long m) {
        long j = 0;
        while(m > 0) {
            if((m & 1) > 0) {
                a = list[a][j];
            }
            ++j;
            m >>= 1;
        }
        return a;
    }
    long search(long a, long b) {
        long u = N;
        long l = 0;
        while(u-l > 1) {
            long m = (u+l) / 2;
            auto c = calc(a, m);
            if(c < b) {
                l = m;
            } else {
                u = m;
            }
        }
        return u;
    }

    auto Q = readLong();
    foreach(i; iota(Q)) {
        long a, b;
        readlnTo(a, b);
        if(a > b) {
            swap(a, b);
        }

        writeln(search(a-1, b-1));
    }
}
