fun main(args: Array<String>) = yorukatsu11f()

fun yorukatsu11f() {
    val (n, k, q) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }

    val drop = aList.sorted().take(q)

    val answer = drop.max()!! - drop.min()!!

    println(answer)
}
