let
    n::Int = parse(Int, readline())
    x::Vector{Int} = map(x -> parse(Int, x), split(readline()))
    l::Int = parse(Int, readline())
    q::Int = parse(Int, readline())
    const lg = 3
    F = Array(Int, lg, n)
    B = Array(Int, lg, n)
    for i = 1:n
        F[1,i] = searchsortedlast(x, x[i]+l)
        B[1,i] = searchsortedfirst(x, x[i]-l)
    end

    for fe = 2:lg
        for i = 1:n
            F[fe,i] = F[fe-1,F[fe-1,i]]
            B[fe,i] = B[fe-1,B[fe-1,i]]
        end
    end
    
    for i = 1:q
        a::Int, b::Int = map(x -> parse(Int, x), split(readline()))
        ans = 1
        if a < b
            for fe = lg:-1:1
                if F[fe,a] < b
                    a = F[fe,a]
                    ans += 2^(fe-1)
                end
            end
        else
            for fe = lg:-1:1
                if B[fe,a] > b
                    a = B[fe,a]
                    ans += 2^(fe-1)
                end
            end
        end
        println(ans)
    end
end
