defmodule Main do

  def main do
    [x, _n] = IO.gets("")
             |> String.trim()
             |> String.split()
             |> Enum.map(&String.to_integer/1)

    p    = IO.gets("")
           |> String.trim()
           |> String.split()
           |> Enum.map(&String.to_integer/1)

    right = x..101 |> Stream.filter(fn x -> not Enum.member?(p, x) end) |> Enum.take(1) |> List.first()
    left  = x..0   |> Stream.filter(fn x -> not Enum.member?(p, x) end) |> Enum.take(1) |> List.first()

    [left, right] |> Enum.sort(&(abs(&1-x) <= abs(&2-x))) |> List.first()
                  |> IO.puts()

  end
end
