import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)

    var (x,n) = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
    if(n==0)
        println(x)


    else {
        var arr = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
        var p = x
        while (true) {
            if (!arr.contains(p))
                break
            else
                p++
        }
        var q = x
        while (true) {
            if (!arr.contains(q))
                break
            else
                q--
        }
        var s1 = Math.abs(p - x)
        var s2 = Math.abs(q - x)
        var ans = Math.min(s1, s2)
        if (ans == s2)
            println(q)
        else
            println(p)
    }
}
