import kotlin.math.abs

fun main() {
    val inLine = readLine()!!.split(" ").map(String::toInt)
    val x = inLine[0]
    val n = inLine[1]
    var pList = mutableListOf<Int>()
    var result = 0
    if (n == 0){
        result = x
    }else{
        pList = readLine()!!.split(" ").map(String::toInt).toMutableList()

        val lxList = mutableListOf<Int>()
        val bxList = mutableListOf<Int>()
        var minP1 = Integer.MAX_VALUE
        var minP2 = Integer.MAX_VALUE

        pList.forEach{
            if(it > x){
                bxList.add(it)
            }else if(it < x){
                lxList.add(it)
            }
        }
        bxList.add(x)
        lxList.add(x)


        var baseX = x + 1

        if(bxList.isEmpty()){
            minP1 = baseX
        }else{
            run loop@{
                while(bxList.isNotEmpty()){
                    if(!bxList.contains(baseX)){
                        minP1 = baseX
                        return@loop
                    }else{
                        bxList.remove(baseX)
                    }
                    baseX++
                }
            }
        }

        baseX = x - 1
        if(lxList.isEmpty()){
            minP2 = baseX
        }else{
            run loop@{
                while(lxList.isNotEmpty()){
                    if(!lxList.contains(baseX)){
                        minP2 = baseX
                        return@loop
                    }else{
                        lxList.remove(baseX)
                    }
                    baseX--
                }
            }
        }


        result = if(!pList.contains(x)) x else if(abs(x - minP1) < abs(x - minP2)) minP1 else minP2
    }
    println(result)
}