let read_ints () =
  let str = read_line() in
  List.map (fun x -> int_of_string x) (Str.split (Str.regexp " +") str)
;;

let rec create_range (x : int) =
  if x = 0 then
    [0]
  else
    0 :: (List.map (fun x -> x + 1) (create_range (x - 1)) )
;;

let rec min_list (x : int list) =
  match x with
  |[] -> 1234567
  |h :: t -> min h (min_list t)
;;

let str1 = read_ints() in
let p = read_ints() in
let x2 = List.nth str1 0 in
let n = List.nth str1 1 in
let all_numbers = create_range 101 in
let all_numbers2 = List.filter (fun x -> not (List.exists (fun y -> y = x) p)) all_numbers in
let dist = List.map (fun x -> abs(x - x2)) all_numbers2 in
let mini = min_list dist in
let ans = List.find (fun x -> abs(x - x2) = mini) all_numbers2 in
print_endline (string_of_int ans)
