fun main(args : Array<String>) {
    val (x, n) = readLine()!!.split(" ").map { it.toInt() }
    val pp = if (n == 0) listOf() else readLine()!!.split(" ").map { it.toInt() }

    var min = Int.MAX_VALUE
    var diff = 0

    // forward
    for (i in x..101) {
        if (!pp.contains(i)) {
            min = i
            diff = i-x
            break
        }
    }

    // backwards
    for (i in x downTo 0) {
        if (!pp.contains(i)) {
            val tmpDiff = x-i
            if (diff == tmpDiff) {
                min = Math.min(min, i)
            }
            if (diff > tmpDiff) {
                min = i
            }
            break
        }
    }

    println(min)
}