import Foundation
func toTuple<T>(_ args: [T]) -> (T, T) { (args[0], args[1]) }
func toTuple<T>(_ args: [T]) -> (T, T, T) { (args[0], args[1], args[2]) }
func toTuple<T>(_ args: [T]) -> (T, T, T, T) { (args[0], args[1], args[2], args[3]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }
func readDoubles() -> [Double] { readLine()!.split(separator: " ").map { Double($0)! } }
func readStrings() -> [String] { readLine()!.split(separator: " ").map { String($0) } }

let (x, n) = toTuple(readInts())
guard n != 0 else { print(x); exit(0)}
let pi = readInts()

var dec = x, inc = x
if !pi.contains(x) { print(x); exit(0) }
while true {
  inc += 1
  dec -= 1
  if (!pi.contains(inc) && !pi.contains(dec)) {
    print(dec)
    break
  } else if (!pi.contains(inc) && pi.contains(dec)) {
    print(inc)
    break
  } else if (pi.contains(inc) && !pi.contains(dec)) {
    print(dec)
    break
  }
}