import kotlin.math.abs

fun main(args: Array<String>) {
    val (X, N) = readLine()!!.split(" ").map{it.toInt()}
    if(N < 1) {
      println(X)
      return
    }
    val numbers = readLine()!!.split(" ").map { it.toInt() }.sorted()
  
    val lastNum = numbers.last() + 1
    fun absCalc(counter: Int, minNum: Int, nums: List<Int> = numbers, target: Int = X): Int {
        val newMinNum = if (!nums.contains(counter) && abs(target - counter) <= abs(target - minNum)) {
            counter
        } else minNum

        return if (numbers.first() - 1 > counter) newMinNum else absCalc(counter - 1, newMinNum)
    }
    println(absCalc(lastNum, lastNum))
}
