fun main(args: Array<String>) {
    val (X, N) = readLine()!!.split(" ").map { it.toInt() }

    if (N == 0) {
        println(X)
        return
    }

    val P = readLine()!!.split(" ").map { it.toInt() }

    if (!P.contains(X)) {
        println(X)
        return
    }

    var count = 0
    var sub = -1
    while (true) {
        if (!P.contains(X + sub)) {
            println(X + sub)
            return
        }

        count += 1
        if ((count % 2) == 0) {
            sub = (sub +1) * -1
            continue
        } else {
            sub *= -1
            continue
        }
    }
}