
function main(input) {
    let [X, N, ...ps] = input.trim().split(/[\s\n]/).map(Number)
    
    let down = X
    let up = X

    let changed = false
    do {
        changed = false
        for(const p of ps) {
            if(down === p) {
                down--
                changed = true
            }

            if(up === p) {
                up++
                changed = true
            }
        }
    } while(changed)

    const d = Math.abs(down - X)
    const u = Math.abs(up - X)
    
    if(d === u || d < u) {
        console.log(down)
    } else {
        console.log(up)
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"))
