import java.util.*

fun simple(a: Int, b: Int, x: List<Long>, L: Long): Int {
    var res = 0
    var v = a
    while (v < b) {
        v = x.indexOfLast { it <= x[v] + L }
        res++
    }

    return res
}

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()

    // solve
    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
    }


    // check
//    val A = ArrayList<Int>()
//    val B = ArrayList<Int>()
//    for (i in 0 until M) for (j in i + 1 until M) {
//        A.add(i)
//        B.add(j)
//    }
//    val a = A.toTypedArray()
//    val b = B.toTypedArray()

    solve(a, b, x, N, L)
}

private fun solve(
    a: Array<Int>,
    b: Array<Int>,
    x: List<Long>,
    N: Int,
    L: Long
) {
    val mp = TreeMap<Long, Int>()
    x.forEachIndexed { index, l -> mp[l] = index }

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

    for (i in x.indices) {
        var value = mp.floorEntry(x[i] + L).value
        if (value == i) {
            value = x.size - 1
        }
        doubling[i][0] = 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 (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
        }

        // solve
        println(res)

        // check
//        val res2 = simple(a[l], b[l], x, L)
//        if (res != res2) {
//            println("${a[l]} ${b[l]}, $res $res2")
//        }
    }
}
