let ($) f g = fun x -> g (f x)
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let (x, n) = Scanf.sscanf (read_line ()) "%d %d" @@ fun x n -> (x, n)
let p = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let () =
  Printf.printf "%d\n" @@ 
    if n = 0 then x
    else Array.init 102 (fun i -> i - 1)
      |> Array.to_list
      |> List.filter (fun i -> not (List.mem i p))
      (* |> (fun acc -> List.iter (Printf.printf "%d ") acc; acc) *)
      |> List.map (fun i -> (abs (i - x), i))
      |> List.sort compare
      |> (List.hd $ snd)