private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private inline fun <T> T.also(block: (T) -> Unit): T { block(this); return this }


fun main(args: Array<String>) {
    val (N, K, Q) = readInts()
    val A = readInts()

    var remainingOp = Q
    val groups = A.groupBy { it }.mapValues { it.value.size }

    val largest = groups.entries.toList().sortedBy { it.key }.takeWhile { targetEntry ->
        (remainingOp > 0).also {
            remainingOp -= targetEntry.value
        }
    }.last().key

    println(largest - groups.keys.min()!!)
}