open Batteries
let x, n = Scanf.sscanf (read_line()) "%d %d" (fun  x n-> x ,n)
let p_ = read_line ()
let p = (if p_ = "" then [] else p_ |> String.split_on_char ' ' |> List.map int_of_string)
let rec loop i =
  if List.mem (x - i) p then 
  if List.mem (x + i) p then (loop (i+1))
  else (x + i)
  else (x - i)
let _ = Printf.printf "%d\n" @@ loop 0