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

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

    var partialCount = 0
    val groups = A.groupBy { it }.mapValues { it.value.size }

    val largest = groups.entries.toList().sortedBy { it.key }.takeWhile {
        partialCount += it.value
        partialCount <= Q
    }.last().key

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