import kotlin.math.abs

fun main() {
    val line = readLine()!!.split(" ").map { it.toInt() }
    val x = line[0]
    val n = line[1]
    val pList = if (n > 0) {
        readLine()!!.split(" ").map { it.toInt() }
    } else {
        readLine()
        listOf()
    }

    if (n == 0) {
        print(x)
        return
    }

    if (!pList.contains(x)) {
        print(x)
        return
    }

    var i = x - 1
    while (true) {
        if (pList.contains(i)) {
            i -= 1
        } else {
            break
        }
    }

    var j = x + 1
    while (true) {
        if (pList.contains(j)) {
            j += 1
        } else {
            break
        }
    }

    val result = if (abs(x - i) > abs(j - x)) {
        j
    } else {
        i
    }
    print(result)

}