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

    var count = 0
    while(true){
        if(!pList.contains((X-count).toString())) {
            X = X-count
            break
        }
        if(!pList.contains((X+count).toString())) {
            X = X+count
            break
        }
        count++
    }
    
    println(X)
}
