import java.util.*

fun main() {

    val sc = Scanner(System.`in`)
    val n : Int = sc.nextInt()
    val m : Int = sc.nextInt()
    var k : Int = sc.nextInt()
    val a = IntArray(n)
    var count = n

    for (i in 0 until n) a[i] = sc.nextInt()
    Arrays.sort(a)

    while (k < m && count > 0) {
        count--
        k += a[count] - 1
    }

    if (k < m) print(-1)
    else print(n - count)

}


import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val n = jin.readLine().toInt()
    val piles = jin.readLine().split(" ").map { it.toInt() }
    println(if (piles.count { it == piles.min() } <= n / 2) "Alice" else "Bob")
}


import kotlin.math.min

fun main() {
    val n = readLine()!!.toInt()
    val ys = IntArray((2 * n) + 1)
    val line = readLine()!!
    for (i in 0 until 2 * n) {
        ys[i + 1] = ys[i] + if (line[i % n] == '(') 1 else -1
    }
    if (ys[n] != 0) {
        println(0)
        println("1 1")
        return
    }
    val low = ys.min()!!
    val sums = Array(3) { IntArray((2 * n) + 1) }
    //println("ys = ${ys.contentToString()}")
    //println("low = $low")
    for (i in 1..2 * n) {
        for (j in 0..2) {
            sums[j][i] = sums[j][i - 1]
        }
        if (ys[i] - low <= 2) {
            sums[ys[i] - low][i]++
        }
    }
    /*for (j in 0..2) {
        println("sums[$j] = ${sums[j].contentToString()}")
    }*/
    val last = IntArray(2)
    val nearest = Array(2) { IntArray(n + 1) }
    for (i in 2 * n downTo 1) {
        if (ys[i] - low <= 1) {
            last[ys[i] - low] = i
        }
        if (i <= n) {
            for (j in 0..1) {
                nearest[j][i] = last[j]
            }
        }
    }
    /*for (j in 0..1) {
        println("nearest[$j] = ${nearest[j].contentToString()}")
    }*/
    var answer = sums[0][n]
    var al = 1
    var ar = 1
    for (i in 1..n) {
        if (line[i - 1] == '(') {
            var j = min(nearest[0][i], nearest[1][i])
            var pos = sums[0][n] + sums[2][j - 1] - sums[2][i - 1]
            if (pos > answer) {
                answer = pos
                al = i
                ar = j
            }
            if (nearest[1][i] < nearest[0][i]) {
                j = nearest[0][i]
                pos = sums[1][j - 1] - sums[1][i - 1]
                if (pos > answer) {
                    answer = pos
                    al = i
                    ar = j
                }
            }
        }
    }
    println(answer)
    println("$al ${((ar - 1) % n) + 1}")
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import kotlin.math.max
import kotlin.math.min

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val out = StringBuilder()
    for (c in 1..jin.readLine().toInt()) {
        val n = jin.readLine().toInt()
        var intervalLeft = 1L
        var intervalRight = Int.MAX_VALUE.toLong()
        val treeSet = TreeSet<Long>()
        var answer = (2 * n) + 1
        val tokenizer = StringTokenizer(jin.readLine())
        var sign = true
        var constant = 0L
        for (j in 1..n) {
            val k = tokenizer.nextToken().toLong()
            if (sign) {
                if (k % 2L == 0L) {
                    val h = k / 2L
                    if (h - constant in intervalLeft..intervalRight || h - constant in treeSet) {
                        answer -= 2
                        intervalLeft = h - constant
                        intervalRight = h - constant
                        treeSet.clear()
                        treeSet.add(h - constant)
                    } else {
                        answer--
                        treeSet.add(h - constant)
                        intervalLeft = max(intervalLeft, 1L - constant)
                        intervalRight = min(intervalRight, k - 1L - constant)
                        while (treeSet.isNotEmpty() && treeSet.first() < 1L - constant) {
                            treeSet.remove(treeSet.first())
                        }
                        while (treeSet.isNotEmpty() && treeSet.last() > k - 1L - constant) {
                            treeSet.remove(treeSet.last())
                        }
                    }
                } else {
                    intervalLeft = max(intervalLeft, 1L - constant)
                    intervalRight = min(intervalRight, k - 1L - constant)
                    while (treeSet.isNotEmpty() && treeSet.first() < 1L - constant) {
                        treeSet.remove(treeSet.first())
                    }
                    while (treeSet.isNotEmpty() && treeSet.last() > k - 1L - constant) {
                        treeSet.remove(treeSet.last())
                    }
                    if (intervalLeft > intervalRight && treeSet.isEmpty()) {
                        intervalLeft = 1L - constant
                        intervalRight = k - 1L - constant
                    } else {
                        answer--
                    }
                }
            } else {
                if (k % 2L == 0L) {
                    val h = k / 2L
                    if (constant - h in intervalLeft..intervalRight || constant - h in treeSet) {
                        answer -= 2
                        intervalLeft = constant - h
                        intervalRight = constant - h
                        treeSet.clear()
                        treeSet.add(constant - h)
                    } else {
                        answer--
                        treeSet.add(constant - h)
                        intervalLeft = max(intervalLeft, constant - (k - 1L))
                        intervalRight = min(intervalRight, constant - 1L)
                        while (treeSet.isNotEmpty() && treeSet.first() < constant - (k - 1L)) {
                            treeSet.remove(treeSet.first())
                        }
                        while (treeSet.isNotEmpty() && treeSet.last() > constant - 1L) {
                            treeSet.remove(treeSet.last())
                        }
                    }
                } else {
                    intervalLeft = max(intervalLeft, constant - (k - 1L))
                    intervalRight = min(intervalRight, constant - 1L)
                    while (treeSet.isNotEmpty() && treeSet.first() < constant - (k - 1L)) {
                        treeSet.remove(treeSet.first())
                    }
                    while (treeSet.isNotEmpty() && treeSet.last() > constant - 1L) {
                        treeSet.remove(treeSet.last())
                    }
                    if (intervalLeft > intervalRight && treeSet.isEmpty()) {
                        intervalLeft = constant - (k - 1L)
                        intervalRight = constant - 1L
                    } else {
                        answer--
                    }
                }
            }
            constant = k - constant
            sign = !sign
        }
        out.appendln(answer)
    }
    print(out)
}