import Foundation
 
let imput = readLine()!.components(separatedBy: " ").map{Int($0)!}
let X = imput[0]
let N = imput[1]
let num = readLine()!
 
if num == ""{
    print(X)
}else {
    let pNums = num.components(separatedBy: " ").map{Int($0)!}
    var nums: [Int] = []
    var min = 100
    var minNum = 0
    
    // -5 から 105 までの配列を作る
    for i in -5...105 {
        nums.append(i)
    }
    
    // nums からpNums を取り除く
    for pNum in pNums {
        
        for (index, num) in nums.enumerated() {
            if pNum == num {
                nums.remove(at: index)
            }
        }
    }
//    for i in 0...N - 1 {
//        for j in 0...101 - N {
//            if pNums[i] == nums[j] {
//                nums.remove(at: j)
//            }
//        }
//    }
    
    
    
    for num in nums {
        let a = abs(num - X)
        if min >= a {
            min = a
            minNum = num
        }
    }
    
//    for i in (0...101 - N) {
//        let a = abs(nums[i] - X)
//        if min >= a {
//            min = a
//            minNum = nums[i]
//        }
//
//    }
    
    print(minNum)
}
