let xn = readLine()!.split(separator: " ").map { Int($0)! }
let (x, n) = (xn[0], xn[1])
let p = readLine()!.split(separator: " ").map { Int($0)! }

for num in 0...1000 {
  let a = x - num
  if !p.contains(a) {
    print(a)
    break
  }
  let b = x + num 
  if !p.contains(b) {
    print(b)
    break
  }
}
