let xn = readLine()!.split(separator: " ").map{Int($0)!}
let x = xn[0]
let n = xn[1]
let pArray = readLine()!.split(separator: " ").map{Int($0)!}
var lastSmallerX: Int?
var firstBiggerX: Int?

for i in 0...101 {
    if i > x {
        if pArray.contains(i) {
            continue
        } else {
            firstBiggerX = i
            break
        }
    } else {
        if pArray.contains(i) {
            continue
        } else {
            lastSmallerX = i
            continue
        }
    }
}

print(x - lastSmallerX <= firstBiggerX - x ? lastSmallerX! : firstBiggerX!)
