import kotlin.math.abs

fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (x, n) = intList()
    if (n == 0) {
        println(x.toString())
    } else {
        val p = intList()
        (0.until(102).toList() - p).map { Pair(it, abs(x - it)) }
            .groupBy { it.second }
            .minBy { it.key }
            ?.value?.minBy { it.first }
            ?.let {
                println(it.first.toString())
                return
            }
        println("0")
    }
}