N = gets.to_i
xs = gets.split.map(&:to_i)
L = gets.to_i

right = Array.new(N.bit_length){Array.new(N)}
r = 1
(N-1).times do |l|
    while r < N && xs[r] - xs[l] <= L
        r += 1
    end
    right[0][l] = r - 1
end

(1...N.bit_length).each do |k|
    (N-1).times do |l|
        break unless right[k-1][l]
        right[k][l] = right[k-1][right[k-1][l]]
        break unless right[k][l]
    end
end

Q = gets.to_i
Q.times do
    a, b = gets.split.map(&:to_i).sort
    ans = 0
    (N.bit_length-1).downto(0) do |k|
        if right[k][a] && right[k][a] <= b
            ans += 1<<k
            a += right[k][a]
        end
    end
    ans += 1 if a < b
    puts ans
end
