fun main() {
    val (x, n) = readLine()!!.split(" ").map { it.toInt() }
    if (n == 0) {
        println(x)
        return
    }

    val list = readLine()!!.split(" ").map { it.toInt() }.sortedDescending()
    var diff = 0
    while (true) {
        val min = x - diff
        if (!list.contains(min)) {
            println(min)
            return
        }
        val max = x + diff
        if (!list.contains(max)) {
            println(max)
            return
        }

        diff += 1
    }
}