let x, n =
    stdin.ReadLine().Split()
    |> Array.map int
    |> fun a -> a.[0], a.[1]

let ary =
    try
        stdin.ReadLine().Split() |> Array.map int
    with _ -> [||]

let rec solve i =
    if not (Array.exists (fun p -> p = x - i) ary)
    then x - i
    elif not (Array.exists (fun p -> p = x + i) ary)
    then x + i
    else solve (i + 1)

solve 0 |> printfn "%d"
