fun main(args: Array<String>) {
    var (x, n) = readLine()!!.split(" ").map { it.toInt() }
    val planePInput = readLine()
    val pList = if (planePInput.isNullOrEmpty()) {
        null
    } else {
        planePInput.split(" ").map { it.toInt() }
    }

    var distance = 0
    val forbiddenList: ArrayList<Int>
    if (pList == null) {
        println(x)
    } else {
        forbiddenList = pList as ArrayList<Int>
        while (true) {
            if (forbiddenList.contains(x - distance)) {
                if (forbiddenList.contains(x + distance)) {
                    distance++
                    continue
                } else {
                    println(x + distance)
                    break
                }
            } else {
                println(x - distance)
                break
            }
        }
    }
}