import Foundation

let values = readLine()!.components(separatedBy: " ").map({Int($0)!})
let X = values[0]
let N = values[1]

if N == 0 {
    print(X)
    exit(0)
}

let numbers = readLine()!.components(separatedBy: " ").map({Int($0)!}).sorted()
// numbersの中に含まれない数を抜き出す
let targetValues = [Int]((numbers[0]-1)...(numbers[N-1]+1)).filter{!numbers.contains($0)}

print(targetValues)
if targetValues.count == 0 {
    // 全て連続していた場合
    print(X)
    exit(0)
}

// Xとの絶対値が一番小さいものを探す
var ans = X
var diff = Int.max
for val in targetValues {
    let tmp = abs(val - X)
    if tmp < diff {
        ans = val
        diff = tmp
    }
}

print(ans)

