let x, n = Scanf.scanf "%d %d" (fun x n -> x, n)
let b = Array.make 102 false

let rec f i =
  if i < n then (
    Scanf.scanf " %d" (fun p -> b.(p) <- true);
    f (i + 1)
  )

let rec g i x =
  if b.(x) then
    let i' =
      if i > 0 then -i - 1
      else -i + 1 in
    g i' (x + i)
  else x

let () =
  f 0;
  let ans = g ~-1 x in
  Printf.printf "%d\n" ans
