fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val D = readLine()!!.split(" ").map(String::toInt)

    val map = D.groupBy{ it }.mapValues { it.value.size }.toSortedMap()


    val avgPreIndex = N / 2
    var sum = 0
    var avgPreNumber = 0
    var avgNextNumber = 0
    for ((k, v) in map) {
        sum += v

        if (avgPreNumber != 0) {
            avgNextNumber = k
            break
        }
        if (sum == avgPreIndex) {
            avgPreNumber = k

        }
        if (sum > avgPreIndex) {
            println(0)
            return
        }
    }

    println(avgNextNumber - avgPreNumber)


}