object Main extends App {
    val Array(x, n) = io.StdIn.readLine.split(" ").map(_.toInt)
    
    if (n == 0) println(x)
    else {
        val ps = io.StdIn.readLine.split(" ").map(_.toInt)

        val ints = ((ps.min-1) to (ps.max+1)).toSet &~ ps.toSet

        def rec(diff: Int): Int = {
            if (ints.contains(x-diff)) x-diff
            else if (ints.contains(x+diff)) x+diff
            else rec(diff+1)
        }

        val result = rec(0)
        println(result)
    }
}