open Printf
open Scanf

let id x = x
             
let solve x n =
  if n = 0 then x
  else let lp = List.init n @@ fun _ -> scanf "%d " id in
       let rec loop i =
         if not @@ List.mem (x - i) lp then (x - i)
         else if not @@ List.mem (x + i) lp then (x + i)
         else loop (i + 1) in
       loop 0

let () =
  scanf "%d %d " solve |> printf "%d\n"
