import java.util.*

fun main(args: Array<String>) {
    val M = readLine()!!.toInt()
    var N = 1
    while (N < M) N *= 2
    val x = readLine()!!.split(" ").map{it.toLong()}
    val L = readLine()!!.toLong()
    val Q = readLine()!!.toInt()
    val a = Array(Q) { 0 }
    val b = Array(Q) { 0 }

    for (i in a.indices) {
        val (A, B) = readLine()!!.split(" ").map{it.toInt()}
        a[i] = Math.min(A, B) - 1
        b[i] = Math.max(A, B) - 1
    }

    val mp = TreeMap<Long, Int>()
    x.forEachIndexed { index, l -> mp[l] = index }

    val doubling = Array(N) { Array(20) { N - 1 } }

    for (i in x.indices) {
        doubling[i][0] = mp.floorEntry(x[i] + L)?.value ?: mp.lastEntry().value
    }

    for (k in 1 until 20) {
        for (i in doubling.indices) {
            doubling[i][k] = doubling[doubling[i][k - 1]][k - 1]
        }
    }

    fun findNext(s: Int, t: Int): Pair<Int, Int> {
        var k = doubling[s].indexOfFirst { it >= t }
        if (doubling[s][k] > t && k > 0) k--

        return Pair(doubling[s][k], 1 shl k)
    }

    for (l in a.indices) {
        var res = 0

        var v = a[l]
        while (v < b[l]) {
            val p = findNext(v, b[l])
            v = p.first
            res += p.second
        }
        println(res)
    }
}
